Interface SlotClickContext

All Superinterfaces:
ViewContext
All Known Implementing Classes:
SlotClickContextImpl

@NonExtendable public interface SlotClickContext extends ViewContext
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 Type
    Method
    Description
    @NotNull org.bukkit.event.inventory.ClickType
    Returns the Bukkit click type of this click.
    boolean
    Returns the current cancellation decision: config/component policy applied before handlers run, possibly overturned by setCancelled(boolean).
    boolean
    Returns whether the click landed in the player's own (bottom) inventory.
    @Nullable org.bukkit.inventory.ItemStack
    Returns the item on the clicked slot, if any.
    @NotNull org.bukkit.event.inventory.InventoryClickEvent
    Returns the underlying Bukkit event as an escape hatch.
    void
    setCancelled(boolean cancelled)
    Overrides the cancellation decision for this click; last writer wins.
    int
    Returns the raw slot id of the clicked container.

    Methods inherited from interface tech.guilhermekaua.spigotboot.inventoryapi.context.ViewContext

    arguments, close, config, inventory, isActive, openView, openView, player, playerId, plugin, update, updateTitle, view
  • 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 null when 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-level onClick.
      Returns:
      true for 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 by setCancelled(boolean).
      Returns:
      true when 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