Interface ConfiguredPluginClassLoader

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
PluginClassLoader

@NullMarked @Internal public interface ConfiguredPluginClassLoader extends Closeable
The configured plugin class loader represents an internal abstraction over the classloaders used by the server to load and access a plugins classes during runtime.

It implements Closeable to define the ability to shutdown and close the classloader that implements this interface.

  • Method Summary

    Modifier and Type
    Method
    Description
    Provides the configuration of the plugin that this plugin classloader provides type access to.
    Get the plugin classloader group that is used by the underlying classloader
    Gets the plugin held by this class loader.
    void
    init(JavaPlugin plugin)
    Initializes both this configured plugin class loader and the java plugin passed to link to each other.
    loadClass(String name, boolean resolve, boolean checkGlobal, boolean checkLibraries)
    Attempts to load a class from this plugin class loader using the passed fully qualified name.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • getConfiguration

      PluginMeta getConfiguration()
      Provides the configuration of the plugin that this plugin classloader provides type access to.
      Returns:
      the plugin meta instance, holding all meta information about the plugin instance.
    • loadClass

      Class<?> loadClass(String name, boolean resolve, boolean checkGlobal, boolean checkLibraries) throws ClassNotFoundException
      Attempts to load a class from this plugin class loader using the passed fully qualified name. This lookup logic can be configured through the following parameters to define how wide or how narrow the class lookup should be.
      Parameters:
      name - the fully qualified name of the class to load
      resolve - whether the class should be resolved if needed or not
      checkGlobal - whether this lookup should check transitive dependencies, including either the legacy spigot global class loader or the paper PluginClassLoaderGroup
      checkLibraries - whether the defined libraries should be checked for the class or not
      Returns:
      the class found at the fully qualified class name passed under the passed restrictions
      Throws:
      ClassNotFoundException - if the class could not be found considering the passed restrictions
      See Also:
    • init

      void init(JavaPlugin plugin)
      Initializes both this configured plugin class loader and the java plugin passed to link to each other. This logic is to be called exactly once when the initial setup between the class loader and the instantiated JavaPlugin is loaded.
      Parameters:
      plugin - the JavaPlugin that should be interlinked with this class loader.
    • getPlugin

      @Nullable JavaPlugin getPlugin()
      Gets the plugin held by this class loader.
      Returns:
      the plugin or null if it doesn't exist yet
    • getGroup

      Get the plugin classloader group that is used by the underlying classloader
      Returns:
      classloader