Class ScalaPluginLoader
java.lang.Object
xyz.janboerman.scalaloader.plugin.ScalaPluginLoader
- All Implemented Interfaces:
PluginLoader
,IScalaPluginLoader
-
Constructor Summary
ConstructorsConstructorDescriptionScalaPluginLoader
(Server server) Per PluginLoader API, the constructor has only one parameter: the Server.ScalaPluginLoader
(ScalaLoader scalaLoader) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addClassGlobally
(ScalaRelease scalaCompat, String className, Class<?> clazz) Make a class visible for allScalaPlugin
s with a binary compatible version of Scala.void
Map
<Class<? extends Event>, Set<RegisteredListener>> createRegisteredListeners
(Listener listener, Plugin plugin) Internal use onlyvoid
disablePlugin
(Plugin plugin) void
enablePlugin
(Plugin plugin) static void
forceLoadAllClasses
(ScalaPlugin scalaPlugin) Deprecated.getAllClasses
(ScalaPlugin scalaPlugin) Get all classes from a scala plugin.Deprecated.useIScalaLoader.getEventBus()
instead.static ScalaPluginLoader
Get the instance that was created when this ScalaPluginLoader was constructed.static JarFile
getJarFile
(ScalaPlugin scalaPlugin) Get the jar file of a ScalaPlugin.getPluginDescription
(File file) Pattern[]
protected Class
<?> getScalaPluginClass
(ScalaRelease scalaCompatRelease, String className) Finds classes fromScalaPlugin
s.Get the ScalaPlugins.loadPlugin
(File file) void
void
openUpToJavaPlugin
(ScalaPlugin scalaPlugin, JavaPlugin javaPlugin) Deprecated.protected boolean
removeClassGlobally
(ScalaRelease scalaCompat, String className, Class<?> clazz)
-
Constructor Details
-
ScalaPluginLoader
-
ScalaPluginLoader
Per PluginLoader API, the constructor has only one parameter: the Server.- Parameters:
server
- the server.
-
-
Method Details
-
getInstance
Get the instance that was created when this ScalaPluginLoader was constructed.- Returns:
- the instance that was created either by bukkit's
PluginManager
or byScalaLoader
, or null if no ScalaPluginLoader was constructed yet. - API Note:
- if you call this method from your own plugin, your plugin must have a dependency on
ScalaLoader
.
-
getEventBus
Deprecated.useIScalaLoader.getEventBus()
instead.Get the event bus.- Returns:
- the event bus
- API Note:
- This method is provided for JavaPlugins. ScalaPlugin's can use
ScalaPlugin.getEventBus()
instead.
-
getScalaPlugins
Get the ScalaPlugins.- Returns:
- an unmodifiable collection containing all ScalaPlugins.
-
debugSettings
Description copied from interface:IScalaPluginLoader
Internal use only- Specified by:
debugSettings
in interfaceIScalaPluginLoader
-
getPluginDescription
- Specified by:
getPluginDescription
in interfacePluginLoader
- Throws:
InvalidDescriptionException
-
getJarFile
Get the jar file of a ScalaPlugin.- Parameters:
scalaPlugin
- the plugin- Returns:
- the jar file
- Throws:
IOException
- if a jarfile could not be created
-
openUpToJavaPlugin
Deprecated.Makes classes from a ScalaPlugin visible to the JavaPlugin's classloader so that the ScalaPlugin can be used by the JavaPlugin.- Parameters:
scalaPlugin
- the scala pluginjavaPlugin
- the java plugin- API Note:
- this only makes the classes that are in the ScalaPlugin's jar file available - that excludes the Scala standard library classes.
-
getAllClasses
Get all classes from a scala plugin.- Parameters:
scalaPlugin
- the scala plugin- Returns:
- an open stream that provides all classes that are in the ScalaPlugin's jar file
- Throws:
IOException
- if the stream could not be opened for whatever reason
-
forceLoadAllClasses
Deprecated.UseopenUpToJavaPlugin(ScalaPlugin, JavaPlugin)
instead. This method used to inject classes from the ScalaPlugin into the 'global' JavaPluginLoader scope, so that JavaPlugins could find classes from the ScalaPlugin. But since it no longer does that, it has no use to call this method anymore. This method will be removed in a future version!Loads all classes in the ScalaPlugin's jar file.- Parameters:
scalaPlugin
- the ScalaPlugin
-
loadPlugin
- Specified by:
loadPlugin
in interfacePluginLoader
- Throws:
InvalidPluginException
UnknownDependencyException
-
loadWhenDependenciesComeAvailable
-
getPluginsWaitingForDependencies
-
clearPluginsWaitingForDependencies
public void clearPluginsWaitingForDependencies() -
enablePlugin
- Specified by:
enablePlugin
in interfacePluginLoader
-
disablePlugin
- Specified by:
disablePlugin
in interfacePluginLoader
-
getPluginFileFilters
- Specified by:
getPluginFileFilters
in interfacePluginLoader
-
createRegisteredListeners
public Map<Class<? extends Event>,Set<RegisteredListener>> createRegisteredListeners(Listener listener, Plugin plugin) - Specified by:
createRegisteredListeners
in interfacePluginLoader
-
addClassGlobally
Make a class visible for allScalaPlugin
s with a binary compatible version of Scala.- Parameters:
scalaCompat
- the compability version of ScalaclassName
- the name of the classclazz
- the class- Returns:
- true if the class was added to the cache of this plugin loader, otherwise false
- Implementation Note:
- scala standard library classes are immediately rejected.
-
removeClassGlobally
-
getScalaPluginClass
protected Class<?> getScalaPluginClass(ScalaRelease scalaCompatRelease, String className) throws ClassNotFoundException Finds classes fromScalaPlugin
s. This method can possibly be called by multiple threads concurrently sinceScalaPluginClassLoader
s are parallel capable.- Parameters:
scalaCompatRelease
- the Scala version the plugin usesclassName
- the name of the class- Returns:
- the class object, if a class with the given name exists, and is binary compatible with the given Scala version
- Throws:
ClassNotFoundException
- if no scala plugin has a class with the given name, or the Scala version is incompatible
-
openUpToJavaPlugin(ScalaPlugin, JavaPlugin)
instead.