Class ScalaPluginLoader

java.lang.Object
xyz.janboerman.scalaloader.plugin.ScalaPluginLoader
All Implemented Interfaces:
PluginLoader, xyz.janboerman.scalaloader.compat.IScalaPluginLoader

public class ScalaPluginLoader extends Object implements PluginLoader, xyz.janboerman.scalaloader.compat.IScalaPluginLoader
  • Constructor Details

    • ScalaPluginLoader

      public ScalaPluginLoader(ScalaLoader scalaLoader)
    • ScalaPluginLoader

      public ScalaPluginLoader(Server server)
      Per PluginLoader API, the constructor has only one parameter: the Server.
      Parameters:
      server - the server.
  • Method Details

    • getInstance

      public static ScalaPluginLoader getInstance()
      Get the instance that was created when this ScalaPluginLoader was constructed.
      Returns:
      the instance that was created either by bukkit's PluginManager or by ScalaLoader, 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 public xyz.janboerman.scalaloader.event.EventBus getEventBus()
      Deprecated.
      use IScalaLoader.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

      public Collection<ScalaPlugin> getScalaPlugins()
      Get the ScalaPlugins.
      Returns:
      an unmodifiable collection containing all ScalaPlugins.
    • debugSettings

      public xyz.janboerman.scalaloader.DebugSettings debugSettings()
      Specified by:
      debugSettings in interface xyz.janboerman.scalaloader.compat.IScalaPluginLoader
    • getPluginDescription

      public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException
      Specified by:
      getPluginDescription in interface PluginLoader
      Throws:
      InvalidDescriptionException
    • getJarFile

      public static JarFile getJarFile(ScalaPlugin scalaPlugin) throws IOException
      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 public void openUpToJavaPlugin(ScalaPlugin scalaPlugin, JavaPlugin javaPlugin)
      Deprecated.
      use IScalaPluginLoader.openUpToJavaPlugin(IScalaPlugin, JavaPlugin) instead.
      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 plugin
      javaPlugin - 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

      public static Stream<? extends Class<?>> getAllClasses(ScalaPlugin scalaPlugin) throws IOException
      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 public static void forceLoadAllClasses(ScalaPlugin scalaPlugin)
      Deprecated.
      Use openUpToJavaPlugin(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 interface PluginLoader
      Throws:
      InvalidPluginException
      UnknownDependencyException
    • loadWhenDependenciesComeAvailable

      public void loadWhenDependenciesComeAvailable(File file)
    • getPluginsWaitingForDependencies

      public Set<File> getPluginsWaitingForDependencies()
    • clearPluginsWaitingForDependencies

      public void clearPluginsWaitingForDependencies()
    • enablePlugin

      public void enablePlugin(Plugin plugin)
      Specified by:
      enablePlugin in interface PluginLoader
    • disablePlugin

      public void disablePlugin(Plugin plugin)
      Specified by:
      disablePlugin in interface PluginLoader
    • getPluginFileFilters

      public Pattern[] getPluginFileFilters()
      Specified by:
      getPluginFileFilters in interface PluginLoader
    • createRegisteredListeners

      public Map<Class<? extends Event>,Set<RegisteredListener>> createRegisteredListeners(Listener listener, Plugin plugin)
      Specified by:
      createRegisteredListeners in interface PluginLoader
    • addClassGlobally

      public boolean addClassGlobally(xyz.janboerman.scalaloader.ScalaRelease scalaCompat, String className, Class<?> clazz)
      Make a class visible for all ScalaPlugins with a binary compatible version of Scala.
      Parameters:
      scalaCompat - the compability version of Scala
      className - the name of the class
      clazz - 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

      protected boolean removeClassGlobally(xyz.janboerman.scalaloader.ScalaRelease scalaCompat, String className, Class<?> clazz)
    • getScalaPluginClass

      protected Class<?> getScalaPluginClass(xyz.janboerman.scalaloader.ScalaRelease scalaCompatRelease, String className) throws ClassNotFoundException
      Finds classes from ScalaPlugins. This method can possibly be called by multiple threads concurrently since ScalaPluginClassLoaders are parallel capable.
      Parameters:
      scalaCompatRelease - the Scala version the plugin uses
      className - 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