Interface SlotClickContext
- All Superinterfaces:
ViewContext
- All Known Implementing Classes:
SlotClickContextImpl
Context for component click handlers and
View.onClick: one instance per
intercepted InventoryClickEvent. Main thread, engine-invoked.
Cancellation is three-layered (config default, per-component override, then
setCancelled(boolean) — last writer wins); the safety floor for cross-inventory
moves is enforced after handlers regardless of their decision.
-
Method Summary
Modifier and TypeMethodDescription@NotNull org.bukkit.event.inventory.ClickTypeReturns the Bukkit click type of this click.booleanReturns the current cancellation decision: config/component policy applied before handlers run, possibly overturned bysetCancelled(boolean).booleanReturns whether the click landed in the player's own (bottom) inventory.@Nullable org.bukkit.inventory.ItemStackitem()Returns the item on the clicked slot, if any.@NotNull org.bukkit.event.inventory.InventoryClickEventrawEvent()Returns the underlying Bukkit event as an escape hatch.voidsetCancelled(boolean cancelled) Overrides the cancellation decision for this click; last writer wins.intslot()Returns the raw slot id of the clicked container.
-
Method Details
-
slot
int slot()Returns the raw slot id of the clicked container.- Returns:
- the clicked raw slot
-
clickType
@NotNull @NotNull org.bukkit.event.inventory.ClickType clickType()Returns the Bukkit click type of this click.- Returns:
- the click type
-
item
@Nullable @Nullable org.bukkit.inventory.ItemStack item()Returns the item on the clicked slot, if any.- Returns:
- the clicked item, or
nullwhen the slot is empty
-
isPlayerInventory
boolean isPlayerInventory()Returns whether the click landed in the player's own (bottom) inventory. Bottom clicks are always pre-cancelled and delivered only to the view-levelonClick.- Returns:
truefor bottom-inventory clicks
-
setCancelled
void setCancelled(boolean cancelled) Overrides the cancellation decision for this click; last writer wins. The safety floor still force-cancels cross-inventory moves after handlers run.- Parameters:
cancelled- whether the underlying event should be cancelled
-
isCancelled
boolean isCancelled()Returns the current cancellation decision: config/component policy applied before handlers run, possibly overturned bysetCancelled(boolean).- Returns:
truewhen the click is currently cancelled
-
rawEvent
@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent rawEvent()Returns the underlying Bukkit event as an escape hatch.- Returns:
- the raw click event
-