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
ConstructorsConstructorDescriptionGuiClickContext(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 aGuiClickContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.event.inventory.InventoryActionaction()Gets the action determined by the server for this click.@Nullable org.bukkit.inventory.InventoryGets the specific inventory that was clicked.org.bukkit.event.inventory.ClickTypeGets the specific type of click performed.@Nullable org.bukkit.inventory.ItemStackGets the item currently residing in the clicked slot.@Nullable org.bukkit.inventory.ItemStackcursor()Gets the item currently held on the mouse cursor.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intGets the hotbar button index if the click type was a number key press.intrawSlot()Gets the raw slot index within the entireInventoryView.intslot()Gets the slot index within the specificclickedInventory().org.bukkit.event.inventory.InventoryType.SlotTypeslotType()Gets the type of the slot that was clicked.org.bukkit.entity.HumanEntitysource()Gets the entity that performed the click.final StringtoString()Returns a string representation of this record class.view()Gets the view of the gui that is open.
-
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 aGuiClickContextrecord class.- Parameters:
source- the value for thesourcerecord componentview- the value for theviewrecord componentclickedInventory- the value for theclickedInventoryrecord componentcurrentItem- the value for thecurrentItemrecord componentcursor- the value for thecursorrecord componentslot- the value for theslotrecord componentrawSlot- the value for therawSlotrecord componentclickType- the value for theclickTyperecord componentaction- the value for theactionrecord componentslotType- the value for theslotTyperecord componenthotbarKey- the value for thehotbarKeyrecord component
-
-
Method Details
-
source
public org.bukkit.entity.HumanEntity source()Gets the entity that performed the click.- Returns:
- The
HumanEntitysource.
-
view
-
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, ornullif clicked outside the window.
-
currentItem
@Nullable public @Nullable org.bukkit.inventory.ItemStack currentItem()Gets the item currently residing in the clicked slot.- Returns:
- The
ItemStackin the slot, ornullif 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, ornullif empty.
-
slot
public int slot()Gets the slot index within the specificclickedInventory().- Returns:
- The slot index.
-
rawSlot
public int rawSlot()Gets the raw slot index within the entireInventoryView.- 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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes.
-