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 {
|
2022-04-23 13:17:35 +08:00
|
|
|
private PluginIdentifier identifier;
|
2022-04-23 09:45:44 +08:00
|
|
|
|
|
|
|
/**
|
2022-04-23 13:17:35 +08:00
|
|
|
* This method is reflected into.
|
|
|
|
*
|
|
|
|
* Set plugin variables.
|
2022-04-23 09:45:44 +08:00
|
|
|
* @param identifier The plugin's identifier.
|
|
|
|
*/
|
2022-04-23 13:17:35 +08:00
|
|
|
private void initializePlugin(PluginIdentifier identifier) {
|
|
|
|
if(this.identifier == null)
|
|
|
|
this.identifier = identifier;
|
|
|
|
else Grasscutter.getLogger().warn(this.identifier.name + " had a reinitialization attempt.");
|
2022-04-23 09:45:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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() { }
|
|
|
|
}
|