Package com.xpdustry.distributor.plugin
Interface MindustryPlugin
- All Known Implementing Classes:
AbstractMindustryPlugin
public interface MindustryPlugin
A better plugin base class. With better methods, SLF4J support, plugin listeners, etc.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(PluginListener listener) Adds aPluginListenerto this plugin.default PathReturns the plugin data directory.org.slf4j.LoggerReturns the logger bound to this plugin.Returns the metadata of this plugin.default voidonClientCommandsRegistration(arc.util.CommandHandler handler) Called afteronServerCommandsRegistration(CommandHandler).default voidonExit()Called when the server is closing.default voidonInit()Called after the plugin factory creation.default voidonLoad()Called afteronClientCommandsRegistration(CommandHandler)just beforeEventType.ServerLoadEvent.default voidonServerCommandsRegistration(arc.util.CommandHandler handler) Called afteronInit().default voidonUpdate()Called every tick while the server is running.static MindustryPluginwrap(mindustry.mod.Plugin plugin) Wraps a regular plugin into aMindustryPlugin.
-
Method Details
-
wrap
Wraps a regular plugin into aMindustryPlugin.- Parameters:
plugin- the plugin to wrap- Returns:
- the wrapped plugin
-
onInit
default void onInit()Called after the plugin factory creation. Initialize your plugin here.Warning: Only call other plugins in this method if they use Distributor too.
-
onServerCommandsRegistration
default void onServerCommandsRegistration(arc.util.CommandHandler handler) Called afteronInit(). Register your server-side commands here.- Parameters:
handler- the server command handler
-
onClientCommandsRegistration
default void onClientCommandsRegistration(arc.util.CommandHandler handler) Called afteronServerCommandsRegistration(CommandHandler). Register your client-side commands here.- Parameters:
handler- the client command handler
-
onLoad
default void onLoad()Called afteronClientCommandsRegistration(CommandHandler)just beforeEventType.ServerLoadEvent. Hook into other plugins here since this method technically replacesMod.init(). -
onUpdate
default void onUpdate()Called every tick while the server is running. -
onExit
default void onExit()Called when the server is closing. Unload your plugin here (closing the database connection, saving files, etc.). -
getDirectory
Returns the plugin data directory../config/mods/[plugin-name]/by default. -
getLogger
org.slf4j.Logger getLogger()Returns the logger bound to this plugin. -
getMetadata
PluginMetadata getMetadata()Returns the metadata of this plugin. -
addListener
Adds aPluginListenerto this plugin.- Parameters:
listener- the listener to add
-