mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-03-26 01:23:11 +01:00
Basic plugin manager
This commit is contained in:
71
src/main/java/emu/grasscutter/plugin/Plugin.java
Normal file
71
src/main/java/emu/grasscutter/plugin/Plugin.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package emu.grasscutter.plugin;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
|
||||
/**
|
||||
* The base class for all plugins to extend.
|
||||
*/
|
||||
public abstract class Plugin {
|
||||
private final PluginIdentifier identifier;
|
||||
|
||||
/**
|
||||
* Empty constructor for developers.
|
||||
* Should not be called by users.
|
||||
*/
|
||||
public Plugin() {
|
||||
this(new PluginIdentifier("", "", "", new String[]{}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for plugins.
|
||||
* @param identifier The plugin's identifier.
|
||||
*/
|
||||
public Plugin(PluginIdentifier identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* The plugin's identifier instance.
|
||||
* @return An instance of {@link PluginIdentifier}.
|
||||
*/
|
||||
public final PluginIdentifier getIdentifier(){
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin's name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return this.identifier.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin's description.
|
||||
*/
|
||||
public final String getDescription() {
|
||||
return this.identifier.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin's version.
|
||||
*/
|
||||
public final String getVersion() {
|
||||
return this.identifier.version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server that initialized the plugin.
|
||||
* @return A server instance.
|
||||
*/
|
||||
public final GameServer getServer() {
|
||||
return Grasscutter.getGameServer();
|
||||
}
|
||||
|
||||
/* Called when the plugin is first loaded. */
|
||||
public void onLoad() { }
|
||||
/* Called after (most of) the server enables. */
|
||||
public void onEnable() { }
|
||||
/* Called before the server disables. */
|
||||
public void onDisable() { }
|
||||
}
|
||||
Reference in New Issue
Block a user