Record Class GuiClickContext

java.lang.Object
java.lang.Record
com.github.darksoulq.abyssallib.server.event.context.gui.GuiClickContext
Record Components:
source - The entity (player) who clicked in the inventory.
view - The Gui View currently open.
clickedInventory - The specific inventory that was clicked, or null if clicked outside.
currentItem - The item currently in the clicked slot, or null if empty/outside.
cursor - The item currently held on the cursor, or null if empty.
slot - The slot index in the specific inventory.
rawSlot - The raw slot index in the inventory view.
clickType - The type of click performed (e.g., LEFT, RIGHT, SHIFT_LEFT).
action - The inventory action that was triggered.
slotType - The type of slot that was clicked.
hotbarKey - The hotbar key pressed (0-8) if applicable, or -1 otherwise.

public record GuiClickContext(org.bukkit.entity.HumanEntity source, GuiView view, @Nullable org.bukkit.inventory.Inventory clickedInventory, @Nullable org.bukkit.inventory.ItemStack currentItem, @Nullable org.bukkit.inventory.ItemStack cursor, int slot, int rawSlot, org.bukkit.event.inventory.ClickType clickType, org.bukkit.event.inventory.InventoryAction action, org.bukkit.event.inventory.InventoryType.SlotType slotType, int hotbarKey) extends Record
A context object representing the details of an inventory click interaction.

This class encapsulates all relevant data when a player clicks within an inventory, including the inventory view, the specific slot clicked, the items involved (cursor and slot), and the type of action performed.

  • Constructor Summary

    Constructors
    Constructor
    Description
    GuiClickContext(org.bukkit.entity.HumanEntity source, GuiView view, @Nullable org.bukkit.inventory.Inventory clickedInventory, @Nullable org.bukkit.inventory.ItemStack currentItem, @Nullable org.bukkit.inventory.ItemStack cursor, int slot, int rawSlot, org.bukkit.event.inventory.ClickType clickType, org.bukkit.event.inventory.InventoryAction action, org.bukkit.event.inventory.InventoryType.SlotType slotType, int hotbarKey)
    Creates an instance of a GuiClickContext record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.event.inventory.InventoryAction
    Gets the action determined by the server for this click.
    @Nullable org.bukkit.inventory.Inventory
    Gets the specific inventory that was clicked.
    org.bukkit.event.inventory.ClickType
    Gets the specific type of click performed.
    @Nullable org.bukkit.inventory.ItemStack
    Gets the item currently residing in the clicked slot.
    @Nullable org.bukkit.inventory.ItemStack
    Gets the item currently held on the mouse cursor.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Gets the hotbar button index if the click type was a number key press.
    int
    Gets the raw slot index within the entire InventoryView.
    int
    Gets the slot index within the specific clickedInventory().
    org.bukkit.event.inventory.InventoryType.SlotType
    Gets the type of the slot that was clicked.
    org.bukkit.entity.HumanEntity
    Gets the entity that performed the click.
    final String
    Returns a string representation of this record class.
    Gets the view of the gui that is open.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GuiClickContext

      public GuiClickContext(org.bukkit.entity.HumanEntity source, GuiView view, @Nullable @Nullable org.bukkit.inventory.Inventory clickedInventory, @Nullable @Nullable org.bukkit.inventory.ItemStack currentItem, @Nullable @Nullable org.bukkit.inventory.ItemStack cursor, int slot, int rawSlot, org.bukkit.event.inventory.ClickType clickType, org.bukkit.event.inventory.InventoryAction action, org.bukkit.event.inventory.InventoryType.SlotType slotType, int hotbarKey)
      Creates an instance of a GuiClickContext record class.
      Parameters:
      source - the value for the source record component
      view - the value for the view record component
      clickedInventory - the value for the clickedInventory record component
      currentItem - the value for the currentItem record component
      cursor - the value for the cursor record component
      slot - the value for the slot record component
      rawSlot - the value for the rawSlot record component
      clickType - the value for the clickType record component
      action - the value for the action record component
      slotType - the value for the slotType record component
      hotbarKey - the value for the hotbarKey record component
  • Method Details

    • source

      public org.bukkit.entity.HumanEntity source()
      Gets the entity that performed the click.
      Returns:
      The HumanEntity source.
    • view

      public GuiView view()
      Gets the view of the gui that is open.
      Returns:
      The GuiView.
    • clickedInventory

      @Nullable public @Nullable org.bukkit.inventory.Inventory clickedInventory()
      Gets the specific inventory that was clicked.

      This may be the top inventory or the bottom (player) inventory.

      Returns:
      The clicked Inventory, or null if clicked outside the window.
    • currentItem

      @Nullable public @Nullable org.bukkit.inventory.ItemStack currentItem()
      Gets the item currently residing in the clicked slot.
      Returns:
      The ItemStack in the slot, or null if empty or clicked outside.
    • cursor

      @Nullable public @Nullable org.bukkit.inventory.ItemStack cursor()
      Gets the item currently held on the mouse cursor.
      Returns:
      The cursor ItemStack, or null if empty.
    • slot

      public int slot()
      Gets the slot index within the specific clickedInventory().
      Returns:
      The slot index.
    • rawSlot

      public int rawSlot()
      Gets the raw slot index within the entire InventoryView.
      Returns:
      The raw slot index.
    • clickType

      public org.bukkit.event.inventory.ClickType clickType()
      Gets the specific type of click performed.
      Returns:
      The ClickType.
    • action

      public org.bukkit.event.inventory.InventoryAction action()
      Gets the action determined by the server for this click.
      Returns:
      The InventoryAction.
    • slotType

      public org.bukkit.event.inventory.InventoryType.SlotType slotType()
      Gets the type of the slot that was clicked.
      Returns:
      The InventoryType.SlotType.
    • hotbarKey

      public int hotbarKey()
      Gets the hotbar button index if the click type was a number key press.
      Returns:
      The button index (0-8), or -1 if not applicable.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.