Contents
Class PluginClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
com.hypixel.hytale.server.core.plugin.PluginClassLoader
- All Implemented Interfaces:
Closeable, AutoCloseable
A class loader used to load plugin classes from
JavaPlugin instances-
Constructor Summary
ConstructorsConstructorDescriptionPluginClassLoader(PluginManager pluginManager, PluginIdentifier identifier, boolean inServerClassPath, boolean childFirst, URL... urls) Constructor for aPluginClassLoaderinstance with child-first class loading support.PluginClassLoader(PluginManager pluginManager, PluginIdentifier identifier, boolean inServerClassPath, URL... urls) Default Constructor for aPluginClassLoaderinstance -
Method Summary
Modifier and TypeMethodDescriptiongetResource(String name) getResources(String name) static booleanisFromThirdPartyPlugin(Throwable throwable) Checks if an exception originated from a third-party plugin by examining the stack trace and classloader hierarchy.booleanClass<?> loadLocalClass(String name) Loads the classes of the currently set pluginMethods inherited from class URLClassLoader
close, findResource, findResources, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class ClassLoader
clearAssertionStatus, getDefinedPackage, getDefinedPackages, getName, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
-
Constructor Details
-
PluginClassLoader
public PluginClassLoader(@Nonnull PluginManager pluginManager, @Nullable PluginIdentifier identifier, boolean inServerClassPath, @Nonnull URL... urls) Default Constructor for aPluginClassLoaderinstance- Parameters:
pluginManager- The affiliated plugin manageridentifier- Optional identifier of the plugin that owns this classloaderinServerClassPath- Whether the plugin is within the server class pathurls- Additional URLs that should be considered
-
PluginClassLoader
public PluginClassLoader(@Nonnull PluginManager pluginManager, @Nullable PluginIdentifier identifier, boolean inServerClassPath, boolean childFirst, @Nonnull URL... urls) Constructor for aPluginClassLoaderinstance with child-first class loading support.- Parameters:
pluginManager- The affiliated plugin manageridentifier- Optional identifier of the plugin that owns this classloaderinServerClassPath- Whether the plugin is within the server class pathchildFirst- When true, loads classes from own URLs before the server classloaderurls- Additional URLs that should be considered
-
-
Method Details
-
isInServerClassPath
public boolean isInServerClassPath()- Returns:
trueif the plugin is within the server class path,falseotherwise
-
loadLocalClass
Loads the classes of the currently set plugin- Parameters:
name- The name of the main class that we are loading from- Returns:
- the loaded
JavaPlugininstance - Throws:
ClassNotFoundException- Thrown if no class was found from any of the attempted loads
-
getResource
- Overrides:
getResourcein classClassLoader
-
getResources
- Overrides:
getResourcesin classClassLoader- Throws:
IOException
-
isFromThirdPartyPlugin
Checks if an exception originated from a third-party plugin by examining the stack trace and classloader hierarchy. Used as a fallback filter for exceptions that bypass plugin loggers.
-