Annotation Interface OnShutdown
Marks a method to be called when the plugin is being unloaded/shutdown.
Unlike OnDisable, this is called when the plugin is being completely
removed (not just disabled). Use this for final cleanup like closing database
connections, stopping threads, clearing caches, etc.
The method can optionally return a boolean:
true- Shutdown completed successfully, core can proceed with unloadfalse- Shutdown had issues, core will force-kill the plugin process
Example:
@OnShutdown
public boolean shutdown(PluginContext context) {
try {
// Close database connections
database.close();
// Stop executor services
executor.shutdownNow();
// Clear caches
cache.clear();
context.log("info", "Plugin shutdown complete");
return true; // Success
} catch (Exception e) {
context.log("error", "Shutdown failed: " + e.getMessage());
return false; // Core will force-kill
}
}
The method can optionally accept a PluginContext parameter. If no return value is specified (void), it's treated as successful.