Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The logic behind this dynamic loading system is as follows:
Extensions Folder: A specific folder (extensions) is created or used within the plugin's directory to store .jar files containing the extensions.
Loading the .jar Files: Each .jar file is dynamically loaded using a URLClassLoader, allowing the classes inside the file to be accessible at runtime.
Searching for Classes: The content of the .jar is scanned to identify classes implementing the SkylliaExtendsAddon interface.
Instantiating Extensions: Classes implementing the interface are dynamically instantiated using Reflection, enabling the creation of objects even if their code is unknown to the main plugin.
Lifecycle of Extensions:
onLoad()
: Called after instantiation to initialize the extension with a reference to the main plugin.onEnable()
: Called after the main plugin starts, allowing the extensions to register commands, listeners, etc.onDisable():
Called when the main plugin shuts down to let extensions clean up their resources.In summary, the main plugin acts as an extension manager, dynamically detecting and enabling additional functionality without integrating it directly into its core code.