Effective Clickable
Behaviour that dispatches left/right-click interactions on custom items.
A shared module bridges Bukkit interact/attack events into registered Data handlers, matching the clicked stack by namespaced key (falling back to material). EventsCallOptions carries the click context.
Two ways to register:
EffectiveItem.addClickHandler — matches only that custom item (by key);
addClickHandler directly with a plain, non-custom stack — since it has no key, matching falls back to org.bukkit.Material, so the handler fires for every stack of that material (e.g. hook all sticks). Handy when you want behaviour on a vanilla material, not a custom item.
Click mapping:
Click.LEFT — left-click on air/block and attacking an entity (the attacked entity is in EventsCallOptions.clickedEntity).
Click.RIGHT — right-click on air/block/entity.
Callback result:
EffectiveAbstractInteract.Result.CANCEL_EVENT cancels the underlying Bukkit event (suppresses the vanilla action — block placement, container open, attack, …).
EffectiveAbstractInteract.Result.ALLOW_EVENT lets the vanilla action proceed.
addClickHandler(Click.RIGHT, { e ->
e.player.sendMessage("used ${'$'}{e.item.type}")
EffectiveAbstractInteract.Result.CANCEL_EVENT
})Types
A registered click handler: which item, which Click, the callback and optional cooldown.
Context passed to an InteractCallback: the player, the clicked item, the click type and hand, plus the clicked block/face/entity when applicable.