Package valorless.rarespawns.compilers
Class DynamicAbilityClassLoader
java.lang.Object
java.lang.ClassLoader
valorless.rarespawns.compilers.DynamicAbilityClassLoader
Dynamic class loader for RareSpawns abilities.
This loader attempts to resolve classes from the plugin's data folder at runtime,
specifically from: {pluginDataFolder}/abilities/compiled/.
It expects a compiled .class file whose filename matches the provided
class name (without package) and defines the class with that name.
Typical use is to hot‑load custom ability implementations that were compiled outside the main plugin JAR. The parent class loader (usually the plugin class loader) is preserved so that standard and plugin classes are still available.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionDynamicAbilityClassLoader(ClassLoader parent) Creates a new dynamic class loader that delegates to the given parent. -
Method Summary
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
DynamicAbilityClassLoader
Creates a new dynamic class loader that delegates to the given parent.- Parameters:
parent- the parent class loader to delegate to for standard lookups
-
-
Method Details
-
findClass
Attempts to find and define a class by reading a compiled class file from disk.Lookup location:
{pluginDataFolder}/abilities/compiled/{name}.class. Thenameis treated as the binary name passed toClassLoader.defineClass(String, byte[], int, int).- Overrides:
findClassin classClassLoader- Parameters:
name- the class name to load (expected to match the filename without the .class suffix)- Returns:
- the defined class instance
- Throws:
ClassNotFoundException- if the class file is missing or cannot be read/defined
-