Custom events
In addition to standard Bukkit events, your scripts can listen to custom events fired by the OpenJS plugin itself. These events allow you to hook into the script lifecycle and other plugin internals.
Listening to Custom Events
Use the same familiar registerEvent
function to listen to these custom events
OpenJS Custom Script Lifecycle Events
1. coolcostupit.openjs.events.ScriptLoadedEvent
Triggered whenever a script gets loaded by the plugin.
registerEvent("coolcostupit.openjs.events.ScriptLoadedEvent", function(event) {
var scriptName = event.getScriptName();
log.info("Script got loaded: " + scriptName);
});
Use this event to perform initialization tasks or logging when scripts start running.
2. coolcostupit.openjs.events.ScriptUnloadedEvent
Triggered whenever a script gets unloaded or disabled.
registerEvent("coolcostupit.openjs.events.ScriptUnloadedEvent", function(event) {
var scriptName = event.getScriptName();
log.info("Script got unloaded: " + scriptName);
});
Summary
Custom events integrate seamlessly with the same
registerEvent
system.These lifecycle events give you control and insight into when scripts start and stop.
Use them to build robust, maintainable script logic around script loading/unloading.
Last updated