Record Class GuiDragContext

java.lang.Object
java.lang.Record
com.github.darksoulq.abyssallib.server.event.context.gui.GuiDragContext
Record Components:
source - The entity (player) who performed the drag.
view - The Gui View currently open.
newCursor - The item that will remain on the cursor after the drag completes.
oldCursor - The item that was on the cursor before the drag started.
type - The type of drag performed (e.g., SINGLE/Right-click drag or EVEN/Left-click drag).
newItems - A map of raw slot IDs to the ItemStacks that will be placed in them.
rawSlots - The set of raw slot IDs involved in the drag.
inventorySlots - The set of converted slot IDs (relative to the specific inventory) involved.

public record GuiDragContext(org.bukkit.entity.HumanEntity source, GuiView view, @Nullable org.bukkit.inventory.ItemStack newCursor, @NotNull org.bukkit.inventory.ItemStack oldCursor, org.bukkit.event.inventory.DragType type, Map<Integer, org.bukkit.inventory.ItemStack> newItems, Set<Integer> rawSlots, Set<Integer> inventorySlots) extends Record
A context object representing the details of an inventory drag interaction.

This class encapsulates all relevant data when a player drags an item across inventory slots, including the items being distributed, the slots affected, and the type of drag operation.

  • Constructor Summary

    Constructors
    Constructor
    Description
    GuiDragContext(org.bukkit.entity.HumanEntity source, GuiView view, @Nullable org.bukkit.inventory.ItemStack newCursor, @NotNull org.bukkit.inventory.ItemStack oldCursor, org.bukkit.event.inventory.DragType type, Map<Integer, org.bukkit.inventory.ItemStack> newItems, Set<Integer> rawSlots, Set<Integer> inventorySlots)
    Creates an instance of a GuiDragContext record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Gets the converted inventory slot IDs to be changed.
    @Nullable org.bukkit.inventory.ItemStack
    Gets the result cursor after the drag is done.
    Map<Integer, org.bukkit.inventory.ItemStack>
    Gets all items to be added to the inventory in this drag.
    @NotNull org.bukkit.inventory.ItemStack
    Gets the cursor item prior to the drag modification.
    Gets the raw slot IDs to be changed in this drag.
    org.bukkit.entity.HumanEntity
    Gets the entity that performed the drag.
    final String
    Returns a string representation of this record class.
    org.bukkit.event.inventory.DragType
    Gets the DragType describing the distribution behavior.
    Gets the view of the gui that is open.

    Methods inherited from class Object

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

    • GuiDragContext

      public GuiDragContext(org.bukkit.entity.HumanEntity source, GuiView view, @Nullable @Nullable org.bukkit.inventory.ItemStack newCursor, @NotNull @NotNull org.bukkit.inventory.ItemStack oldCursor, org.bukkit.event.inventory.DragType type, Map<Integer, org.bukkit.inventory.ItemStack> newItems, Set<Integer> rawSlots, Set<Integer> inventorySlots)
      Creates an instance of a GuiDragContext record class.
      Parameters:
      source - the value for the source record component
      view - the value for the view record component
      newCursor - the value for the newCursor record component
      oldCursor - the value for the oldCursor record component
      type - the value for the type record component
      newItems - the value for the newItems record component
      rawSlots - the value for the rawSlots record component
      inventorySlots - the value for the inventorySlots record component
  • Method Details

    • source

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

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

      @Nullable public @Nullable org.bukkit.inventory.ItemStack newCursor()
      Gets the result cursor after the drag is done.
      Returns:
      The new cursor ItemStack, or null if empty.
    • oldCursor

      @NotNull public @NotNull org.bukkit.inventory.ItemStack oldCursor()
      Gets the cursor item prior to the drag modification.
      Returns:
      The original cursor ItemStack.
    • type

      public org.bukkit.event.inventory.DragType type()
      Gets the DragType describing the distribution behavior.
      Returns:
      The DragType.
    • newItems

      public Map<Integer, org.bukkit.inventory.ItemStack> newItems()
      Gets all items to be added to the inventory in this drag.
      Returns:
      A map from raw slot ID to the new ItemStack to be placed there.
    • rawSlots

      public Set<Integer> rawSlots()
      Gets the raw slot IDs to be changed in this drag.

      These IDs correspond to InventoryView.getItem(int).

      Returns:
      A set of raw slot IDs.
    • inventorySlots

      public Set<Integer> inventorySlots()
      Gets the converted inventory slot IDs to be changed.

      These IDs correspond to Inventory.getItem(int).

      Returns:
      A set of inventory slot IDs.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.