OpenJS-docs
Download plugin
  • Overview
    • Welcome
  • Getting Started
    • Installing the plugin
    • Configuration file
    • Commands
    • Creating scripts
  • OpenJS Components
    • Feature Flags
    • Managing scripts within scripts
    • Sharing variables between scripts
    • Custom Commands
    • Using PlaceHolderApi
    • Listening and cancelling events
    • Custom events
    • Loading and saving data
    • Logging in console
    • Scheduling
    • Java imports
  • Example Scripts
    • spawn hit stand command
    • Knockbackstick command
    • No hit-cooldown script
    • NoBlockPlacing script
    • Saving Player data script
    • running code asynchronously
    • WhileTrue do script
Powered by GitBook
On this page
  1. OpenJS Components

Listening and cancelling events

To listen to an event you need to use the custom "registerEvent" function:

registerEvent(EventName ; string, Listener ; Array)

Example usage:
registerEvent("org.bukkit.event.block.BlockPlaceEvent", {
    handleEvent: function(event) {
        event.getPlayer().sendMessage("You tried to place " + event.getBlock().getType().toString());
        event.setCancelled(true);
    }
});
PreviousUsing PlaceHolderApiNextCustom events

Last updated 7 days ago