Class InventoryClickEvent

    • Method Detail

      • getSlotType

        @NotNull
        public InventoryType.SlotType getSlotType()
        Gets the type of slot that was clicked.
        Returns:
        the slot type
      • getCursor

        @Nullable
        public ItemStack getCursor()
        Gets the current ItemStack on the cursor.
        Returns:
        the cursor ItemStack
      • getCurrentItem

        @Nullable
        public ItemStack getCurrentItem()
        Gets the ItemStack currently in the clicked slot.
        Returns:
        the item in the clicked
      • isRightClick

        public boolean isRightClick()
        Gets whether or not the ClickType for this event represents a right click.
        Returns:
        true if the ClickType uses the right mouse button.
        See Also:
        ClickType.isRightClick()
      • isLeftClick

        public boolean isLeftClick()
        Gets whether or not the ClickType for this event represents a left click.
        Returns:
        true if the ClickType uses the left mouse button.
        See Also:
        ClickType.isLeftClick()
      • isShiftClick

        public boolean isShiftClick()
        Gets whether the ClickType for this event indicates that the key was pressed down when the click was made.
        Returns:
        true if the ClickType uses Shift or Ctrl.
        See Also:
        ClickType.isShiftClick()
      • setCursor

        @Deprecated
        public void setCursor​(@Nullable
                              ItemStack stack)
        Deprecated.
        This changes the ItemStack in their hand before any calculations are applied to the Inventory, which has a tendency to create inconsistencies between the Player and the server, and to make unexpected changes in the behavior of the clicked Inventory.
        Sets the item on the cursor.
        Parameters:
        stack - the new cursor item
      • setCurrentItem

        public void setCurrentItem​(@Nullable
                                   ItemStack stack)
        Sets the ItemStack currently in the clicked slot.
        Parameters:
        stack - the item to be placed in the current slot
      • getClickedInventory

        @Nullable
        public Inventory getClickedInventory()
        Gets the inventory corresponding to the clicked slot.
        Returns:
        inventory, or null if clicked outside
        See Also:
        InventoryView.getInventory(int)
      • getSlot

        public int getSlot()
        The slot number that was clicked, ready for passing to Inventory.getItem(int). Note that there may be two slots with the same slot number, since a view links two different inventories.
        Returns:
        The slot number.
      • getRawSlot

        public int getRawSlot()
        The raw slot number clicked, ready for passing to #getItem(int) This slot number is unique for the view.
        Returns:
        the slot number
      • getHotbarButton

        public int getHotbarButton()
        If the ClickType is NUMBER_KEY, this method will return the index of the pressed key (0-8).
        Returns:
        the number on the key minus 1 (range 0-8); or -1 if not a NUMBER_KEY action
      • getAction

        @NotNull
        public InventoryAction getAction()
        Gets the InventoryAction that triggered this event.

        This action cannot be changed, and represents what the normal outcome of the event will be. To change the behavior of this InventoryClickEvent, changes must be manually applied.

        Returns:
        the InventoryAction that triggered this event.
      • getClick

        @NotNull
        public ClickType getClick()
        Gets the ClickType for this event.

        This is insulated against changes to the inventory by other plugins.

        Returns:
        the type of inventory click
      • getHandlerList

        @NotNull
        public static HandlerList getHandlerList()