Skip to content

Events

uxmEssentials exposes a small set of ordinary Bukkit events at the moments an add-on most often wants to hook: when a kit is about to be claimed, and when a menu opens or is clicked. You listen to them exactly as you would any Bukkit event.

What you can listen to

Internally, each bounded context publishes rich domain events (home created, wallet credited, player warned, and so on) on an in-process bus. Those are consumed by the plugin's own subscribers and are not exposed to external plugins — you cannot @EventHandler on them. The events that are Bukkit-observable, with a HandlerList, are the following:

Event Cancellable Fired when
KitPreClaimEvent Yes A player is about to claim a kit, before it is granted
KitClaimEvent No A kit has been granted to a player
MenuOpenEvent Yes A menu is about to open for a viewer
MenuClickEvent Yes A viewer clicks a slot in a menu

Cancel KitPreClaimEvent to veto a claim (for example to enforce your own eligibility rule); cancel MenuOpenEvent or MenuClickEvent to block an open or a click.

These live in the plugin's api package

The four classes above are the confirmed, externally observable events. For the exact package path and the current, complete set, browse the uxmEssentials api event package (or inspect the jar) rather than relying on a hard-coded import — the plugin is not published to Maven, so your IDE resolves these at runtime off the shared classpath (see Overview).

Folia: events fire on the viewer's region thread

Menu events (MenuOpenEvent, MenuClickEvent) fire on the viewer's own region thread, and kit events fire on the thread that performs the grant. Do only region-safe work in the handler; if you need to touch another region, another entity, or run I/O, hand it off through the appropriate scheduler rather than blocking in the handler.


Listening for them

Register a normal Bukkit listener:

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
// Import the kit/menu events from the uxmEssentials api event package.

public final class MyListener implements Listener {

    @EventHandler
    public void onKitPreClaim(KitPreClaimEvent event) {
        // Veto a claim under your own rule — this event is cancellable.
        if (!eligible(event.getPlayer())) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onMenuOpen(MenuOpenEvent event) {
        // Runs on the viewer's region thread — keep it light.
    }
}

Register it from your onEnable, guarded by the soft-depend so you only wire the listener when uxmEssentials is present:

@Override
public void onEnable() {
    if (getServer().getPluginManager().getPlugin("uxmEssentials") != null) {
        getServer().getPluginManager().registerEvents(new MyListener(), this);
    }
}

That guard matters because your listener's method signatures reference uxmEssentials classes; if the plugin is missing and you register unconditionally, the class won't resolve. Gate registration on the plugin being installed and your add-on stays healthy either way.


Next Steps

  • Overview — soft-depend and the ServicesManager lookup pattern
  • Menu API — extend menus rather than just observing them