Grasscutter/src/main/java/emu/grasscutter/plugin/Plugin.java

72 lines
1.6 KiB
Java
Raw Normal View History

2022-04-23 09:45:44 +08:00
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() { }
}