Class SlotClickContextImpl
java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.context.AbstractViewContext
tech.guilhermekaua.spigotboot.inventoryapi.internal.context.SlotClickContextImpl
- All Implemented Interfaces:
SlotClickContext,ViewContext,StateBackedContext
@Internal
public final class SlotClickContextImpl
extends AbstractViewContext
implements SlotClickContext
Context for component click handlers and
View.onClick: wraps one Bukkit click
event. The cancellation decision lives on an internal flag seeded with the pre-cancel
policy; the routing phase applies the final decision to the raw event after handlers run.-
Constructor Summary
ConstructorsConstructorDescriptionSlotClickContextImpl(@NotNull ViewSession session, @NotNull ViewEngine engine, @NotNull org.bukkit.event.inventory.InventoryClickEvent event, boolean playerInventory, boolean preCancelled) Creates the context for one intercepted click. -
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 bySlotClickContext.setCancelled(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.Methods inherited from class tech.guilhermekaua.spigotboot.inventoryapi.internal.context.AbstractViewContext
arguments, close, config, contextActive, engine, inventory, isActive, openView, openView, owner, player, playerId, plugin, session, stateStore, update, updateTitle, view
-
Constructor Details
-
SlotClickContextImpl
public SlotClickContextImpl(@NotNull @NotNull ViewSession session, @NotNull @NotNull ViewEngine engine, @NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent event, boolean playerInventory, boolean preCancelled) Creates the context for one intercepted click.- Parameters:
session- the clicked sessionengine- the engine dispatching the clickevent- the underlying Bukkit eventplayerInventory- whether the click landed in the player's own (bottom) inventorypreCancelled- the cancellation decision computed from config and component policy
-
-
Method Details
-
slot
public int slot()Description copied from interface:SlotClickContextReturns the raw slot id of the clicked container.- Specified by:
slotin interfaceSlotClickContext- Returns:
- the clicked raw slot
-
clickType
@NotNull public @NotNull org.bukkit.event.inventory.ClickType clickType()Description copied from interface:SlotClickContextReturns the Bukkit click type of this click.- Specified by:
clickTypein interfaceSlotClickContext- Returns:
- the click type
-
item
@Nullable public @Nullable org.bukkit.inventory.ItemStack item()Description copied from interface:SlotClickContextReturns the item on the clicked slot, if any.- Specified by:
itemin interfaceSlotClickContext- Returns:
- the clicked item, or
nullwhen the slot is empty
-
isPlayerInventory
public boolean isPlayerInventory()Description copied from interface:SlotClickContextReturns whether the click landed in the player's own (bottom) inventory. Bottom clicks are always pre-cancelled and delivered only to the view-levelonClick.- Specified by:
isPlayerInventoryin interfaceSlotClickContext- Returns:
truefor bottom-inventory clicks
-
setCancelled
public void setCancelled(boolean cancelled) Description copied from interface:SlotClickContextOverrides the cancellation decision for this click; last writer wins. The safety floor still force-cancels cross-inventory moves after handlers run.- Specified by:
setCancelledin interfaceSlotClickContext- Parameters:
cancelled- whether the underlying event should be cancelled
-
isCancelled
public boolean isCancelled()Description copied from interface:SlotClickContextReturns the current cancellation decision: config/component policy applied before handlers run, possibly overturned bySlotClickContext.setCancelled(boolean).- Specified by:
isCancelledin interfaceSlotClickContext- Returns:
truewhen the click is currently cancelled
-
rawEvent
@NotNull public @NotNull org.bukkit.event.inventory.InventoryClickEvent rawEvent()Description copied from interface:SlotClickContextReturns the underlying Bukkit event as an escape hatch.- Specified by:
rawEventin interfaceSlotClickContext- Returns:
- the raw click event
-