Package ovh.mythmc.gestalt.loader.util
Class PaperPluginClassLoaderUtil
java.lang.Object
ovh.mythmc.gestalt.loader.util.PaperPluginClassLoaderUtil
Utility class for manipulating Paper plugin class loaders via reflection.
Paper uses an isolated class loader system for plugins. This utility provides methods to merge two plugins' class loaders so that one plugin can access the other's classes, and to check whether a class is accessible from a given plugin's class loader.
These operations rely on internal Paper API fields accessed through reflection and may break between Paper versions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAccessible(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String className) Returns whether the given class name is loadable from the given plugin's class loader.static voidmergeClassLoaders(@NotNull org.bukkit.plugin.Plugin pluginToMerge, @NotNull org.bukkit.plugin.Plugin destination) Merges the class loader ofpluginToMergeinto the class loader group ofdestination, allowingdestinationto load classes frompluginToMerge.
-
Method Details
-
mergeClassLoaders
public static void mergeClassLoaders(@NotNull @NotNull org.bukkit.plugin.Plugin pluginToMerge, @NotNull @NotNull org.bukkit.plugin.Plugin destination) Merges the class loader ofpluginToMergeinto the class loader group ofdestination, allowingdestinationto load classes frompluginToMerge.- Parameters:
pluginToMerge- the plugin whose class loader should be made accessibledestination- the plugin that should gain access topluginToMerge's classes
-
isAccessible
public static boolean isAccessible(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String className) Returns whether the given class name is loadable from the given plugin's class loader.- Parameters:
plugin- the plugin whose class loader to queryclassName- the fully qualified name of the class to look up- Returns:
trueif the class is accessible,falseotherwise
-