Class PaperPluginClassLoaderUtil

java.lang.Object
ovh.mythmc.gestalt.loader.util.PaperPluginClassLoaderUtil

public class PaperPluginClassLoaderUtil extends Object
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 Type
    Method
    Description
    static boolean
    isAccessible(@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 void
    mergeClassLoaders(@NotNull org.bukkit.plugin.Plugin pluginToMerge, @NotNull org.bukkit.plugin.Plugin destination)
    Merges the class loader of pluginToMerge into the class loader group of destination, allowing destination to load classes from pluginToMerge.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 of pluginToMerge into the class loader group of destination, allowing destination to load classes from pluginToMerge.
      Parameters:
      pluginToMerge - the plugin whose class loader should be made accessible
      destination - the plugin that should gain access to pluginToMerge'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 query
      className - the fully qualified name of the class to look up
      Returns:
      true if the class is accessible, false otherwise