Interface PaperClassLoaderStorage
The paper classloader storage is also responsible for storing added ConfiguredPluginClassLoader
s into
PluginClassLoaderGroup
s, via registerOpenGroup(ConfiguredPluginClassLoader)
,
registerSpigotGroup(PluginClassLoader)
and registerAccessBackedGroup(ConfiguredPluginClassLoader, ClassLoaderAccess)
.
Groups are differentiated into the global group or plugin owned groups.
- The global group holds all registered class loaders and merely exists to maintain backwards compatibility with spigots legacy classloader handling.
- The plugin groups only contains the classloaders that each plugin has access to and hence serves to properly separates unrelated classloaders.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PaperClassLoaderStorage
instance()
Access to the shared instance of thePaperClassLoaderStorageAccess
.registerAccessBackedGroup
(ConfiguredPluginClassLoader classLoader, ClassLoaderAccess access) Registers a paper configured classloader into a new, access backed group.registerOpenGroup
(ConfiguredPluginClassLoader classLoader) Registers a paper configured plugin classloader into a new open group, with full access to the global plugin class loader group.registerSpigotGroup
(PluginClassLoader pluginClassLoader) Registers a legacy spigotPluginClassLoader
into the loader storage, creating a group wrapping the single plugin class loader with transitive access to the global group.boolean
registerUnsafePlugin
(ConfiguredPluginClassLoader pluginLoader) Registers a configured plugin class loader directly into the global group without adding it to any existing groups.void
unregisterClassloader
(ConfiguredPluginClassLoader configuredPluginClassLoader) Unregisters a configured class loader from this storage.
-
Method Details
-
instance
Access to the shared instance of thePaperClassLoaderStorageAccess
.- Returns:
- the singleton instance of the
PaperClassLoaderStorage
used throughout the server
-
registerSpigotGroup
Registers a legacy spigotPluginClassLoader
into the loader storage, creating a group wrapping the single plugin class loader with transitive access to the global group.- Parameters:
pluginClassLoader
- the legacy spigot plugin class loader to register- Returns:
- the group the plugin class loader was placed into
-
registerOpenGroup
Registers a paper configured plugin classloader into a new open group, with full access to the global plugin class loader group.This method hence allows the configured plugin class loader to access all other class loaders registered in this storage.
- Parameters:
classLoader
- the configured plugin class loader to register- Returns:
- the group the plugin class loader was placed into
-
registerAccessBackedGroup
PluginClassLoaderGroup registerAccessBackedGroup(ConfiguredPluginClassLoader classLoader, ClassLoaderAccess access) Registers a paper configured classloader into a new, access backed group. The access backed classloader group, different from an open group, only has access to the classloaders the passedClassLoaderAccess
grants access to.- Parameters:
classLoader
- the configured plugin class loader to registeraccess
- the class loader access that defines what other classloaders the passed plugin class loader should be granted access to.- Returns:
- the group the plugin class loader was placed into.
-
unregisterClassloader
Unregisters a configured class loader from this storage. This removes the passed class loaders from any group it may have been a part of, including the global group.Note: this method is highly discouraged from being used, as mutation of the classloaders at runtime is not encouraged
- Parameters:
configuredPluginClassLoader
- the class loader to remove from this storage.
-
registerUnsafePlugin
Registers a configured plugin class loader directly into the global group without adding it to any existing groups.Note: this method unsafely injects the plugin classloader directly into the global group, which bypasses the group structure paper's plugin API introduced. This method should hence be used with caution.
- Parameters:
pluginLoader
- the configured plugin classloader instance that should be registered directly into the global group.- Returns:
- a simple boolean flag,
true
if the classloader was registered orfalse
if the classloader was already part of the global group.
-