Skip to content

v3 KamiPlugin

Jake Moore edited this page Dec 21, 2024 · 2 revisions

❗ This Documentation is Outdated! It is recommended to use v4 with its documentation instead.

See V4 Getting Started for more information.

⚠️ Usage ⚠️

This feature is only available in spigot-utils and its inheritors (spigot-jar).

KamiPlugin is an extension of JavaPlugin with additional methods to assist in development, and better integration within the KamiCommon ecosystem.

Startup and Shutdown logging

KamiPlugin asks for users to use non-standard methods for enable and disable:

@Override
public void onEnableInner() {
    // Enable code here
}
@Override
public void onDisableInner() {
    // Disable code here
}

This is because KamiPlugin wraps these methods using pre- and post- methods, which will log the time taken to enable and disable the plugin.

Easier Registrations

KamiPlugin also provides additional methods for registering command bukkit types that will be remembered and disabled when the plugin shuts down.
Here are some examples:

kamiPlugin.registerListener(myListener = new MyListener());
kamiPlugin.registerDisableable(myDisableableObject = new MyDisableableObject());
kamiPlugin.registerTask(myBukkitTask);

// Corresponding methods exist to unregister these objects as well.
kamiPlugin.unregisterListener(myListener);
kamiPlugin.unregisterDisableable(myDisableableObject);
kamiPlugin.unregisterTask(myBukkitTask);

Integration with the Module System

KamiPlugin also provides integration with the module system, providing methods to register modules inside the plugin.
Here is that method:

// The module system will automatically construct (using empty constructor) and register the module.
// It will have its internal config loaded and then startup methods called, along with disable method called on plugin and/or module shutdown.
kamiPlugin.registerModule(CustomEnchantsModule.class);

For more information on the module system, see the Module System page.