refactor: redesign plugin system and enhance message handling

- Move plugin and tool-related classes to a dedicated `Plugin-API` module.
- Introduce a new plugin lifecycle (`onInit`, `onEnable`, `onDisable`) and a more robust `Tool` API.
- Refactor `Core` to use `PrintAdvanceMessageHandler` for improved handling of assistant messages, tool responses, and errors.
- Rename `PluginLoader` to `Loader` and migrate it to `me.zacharias.chat.plugin.loader`.
- Update build configurations and Java toolchains across modules.
- Clean up obsolete plugin annotations and interfaces in the `Core` module.
This commit is contained in:
2026-05-26 16:28:02 +02:00
parent 339b176480
commit f6610777ae
37 changed files with 510 additions and 132 deletions
@@ -0,0 +1,56 @@
package me.zacharias.chat.plugin;
import me.zacharias.chat.plugin.annotations.InjectPluginMetadata;
import me.zacharias.chat.plugin.annotations.PluginEntryPoint;
import me.zacharias.chat.plugin.tool.Tool;
import org.jetbrains.annotations.NotNull;
/**
* Entry point for the plugin, this is required for the plugin to work, and you MUST annotate it with {@link PluginEntryPoint}
*/
public abstract class Plugin {
/**
* This shuld be used if {@link PluginEntryPoint#requireData()} is false (default)
* @apiNote While in this constructor, it is not safe to assume any plugin is loaded other than potentially defined plugins in {@link PluginEntryPoint#dependencies()}. See {@link this#onInit}
*/
public Plugin() {}
/**
* This shuld be used if {@link PluginEntryPoint#requireData()} is true
* @apiNote While in this constructor, it is not safe to assume any plugin is loaded other than potentially defined plugins in {@link PluginEntryPoint#dependencies()}. See {@link this#onInit}
* @param data the {@link Data} generated by the plugin loader
*/
public Plugin(Data data) {}
/**
* This will be called once every plugin has been loaded
*/
public void onInit(){}
/**
* This will be called if the core gets a "fetal" exception or fails to fetch certain info
*/
public void onDisable(){}
/**
* This will be called after all plugins have been initialised; here it is safe to perform potential stuff where you load data from optional dependencies, or similar things
*/
public void onEnable(){}
/**
* The "main" method of a plugin, it will be the one returning a list of all tools you define.
* @return An array of all {@link Tool}s you provide in this plugin, see {@link Tool} for definitions or <a href="https://git.server.4zellen.se/Chat_things/NeuroDock/src/branch/master/MALAPITool">MAL API tool</a> for ideas or examples
*/
public Tool[] getTools(){
return null;
}
/**
* This represents your plugin's Metadata
* @return A {@link PluginMetadata} object representing the metadata for your plugin
*/
@NotNull
public abstract PluginMetadata getMetadata();
}