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 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 session
      engine - the engine dispatching the click
      event - the underlying Bukkit event
      playerInventory - whether the click landed in the player's own (bottom) inventory
      preCancelled - the cancellation decision computed from config and component policy
  • Method Details

    • slot

      public int slot()
      Description copied from interface: SlotClickContext
      Returns the raw slot id of the clicked container.
      Specified by:
      slot in interface SlotClickContext
      Returns:
      the clicked raw slot
    • clickType

      @NotNull public @NotNull org.bukkit.event.inventory.ClickType clickType()
      Description copied from interface: SlotClickContext
      Returns the Bukkit click type of this click.
      Specified by:
      clickType in interface SlotClickContext
      Returns:
      the click type
    • item

      @Nullable public @Nullable org.bukkit.inventory.ItemStack item()
      Description copied from interface: SlotClickContext
      Returns the item on the clicked slot, if any.
      Specified by:
      item in interface SlotClickContext
      Returns:
      the clicked item, or null when the slot is empty
    • isPlayerInventory

      public boolean isPlayerInventory()
      Description copied from interface: SlotClickContext
      Returns whether the click landed in the player's own (bottom) inventory. Bottom clicks are always pre-cancelled and delivered only to the view-level onClick.
      Specified by:
      isPlayerInventory in interface SlotClickContext
      Returns:
      true for bottom-inventory clicks
    • setCancelled

      public void setCancelled(boolean cancelled)
      Description copied from interface: SlotClickContext
      Overrides the cancellation decision for this click; last writer wins. The safety floor still force-cancels cross-inventory moves after handlers run.
      Specified by:
      setCancelled in interface SlotClickContext
      Parameters:
      cancelled - whether the underlying event should be cancelled
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: SlotClickContext
      Returns the current cancellation decision: config/component policy applied before handlers run, possibly overturned by SlotClickContext.setCancelled(boolean).
      Specified by:
      isCancelled in interface SlotClickContext
      Returns:
      true when the click is currently cancelled
    • rawEvent

      @NotNull public @NotNull org.bukkit.event.inventory.InventoryClickEvent rawEvent()
      Description copied from interface: SlotClickContext
      Returns the underlying Bukkit event as an escape hatch.
      Specified by:
      rawEvent in interface SlotClickContext
      Returns:
      the raw click event