Interface InventoryClickHandler

All Known Implementing Classes:
AbstractInventory, AnvilInventory, BeaconInventory, BrewingStandInventory, EnchantmentTableInventory, FurnaceInventory, Inventory, PlayerInventory, VillagerInventory

public sealed interface InventoryClickHandler permits AbstractInventory
Represents an inventory which can receive click input. All methods returning boolean returns true if the action is successful, false otherwise.

See https://wiki.vg/Protocol#Click_Window for more information.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    callClickEvent(@NotNull Player player, Inventory inventory, int slot, @NotNull ClickType clickType, @NotNull ItemStack clicked, @NotNull ItemStack cursor)
     
    boolean
    changeHeld(@NotNull Player player, int slot, int key)
    Called when a Player held click in the inventory
    boolean
    doubleClick(@NotNull Player player, int slot)
    Called when a Player double click in the inventory
    boolean
    dragging(@NotNull Player player, int slot, int button)
     
    boolean
    drop(@NotNull Player player, boolean all, int slot, int button)
    Called when a Player press the drop button
    boolean
    leftClick(@NotNull Player player, int slot)
    Called when a Player left click in the inventory.
    boolean
    middleClick(@NotNull Player player, int slot)
     
    boolean
    rightClick(@NotNull Player player, int slot)
    Called when a Player right click in the inventory.
    boolean
    shiftClick(@NotNull Player player, int slot)
    Called when a Player shift click in the inventory
  • Method Details

    • leftClick

      boolean leftClick(@NotNull @NotNull Player player, int slot)
      Called when a Player left click in the inventory. Can also be to drop the cursor item
      Parameters:
      player - the player who clicked
      slot - the slot number
      Returns:
      true if the click hasn't been cancelled, false otherwise
    • rightClick

      boolean rightClick(@NotNull @NotNull Player player, int slot)
      Called when a Player right click in the inventory. Can also be to drop the cursor item
      Parameters:
      player - the player who clicked
      slot - the slot number
      Returns:
      true if the click hasn't been cancelled, false otherwise
    • shiftClick

      boolean shiftClick(@NotNull @NotNull Player player, int slot)
      Called when a Player shift click in the inventory
      Parameters:
      player - the player who clicked
      slot - the slot number
      Returns:
      true if the click hasn't been cancelled, false otherwise
    • changeHeld

      boolean changeHeld(@NotNull @NotNull Player player, int slot, int key)
      Called when a Player held click in the inventory
      Parameters:
      player - the player who clicked
      slot - the slot number
      key - the held slot (0-8) pressed
      Returns:
      true if the click hasn't been cancelled, false otherwise
    • middleClick

      boolean middleClick(@NotNull @NotNull Player player, int slot)
    • drop

      boolean drop(@NotNull @NotNull Player player, boolean all, int slot, int button)
      Called when a Player press the drop button
      Parameters:
      player - the player who clicked
      all -
      slot - the slot number
      button - -999 if clicking outside, normal if he is not
      Returns:
      true if the drop hasn't been cancelled, false otherwise
    • dragging

      boolean dragging(@NotNull @NotNull Player player, int slot, int button)
    • doubleClick

      boolean doubleClick(@NotNull @NotNull Player player, int slot)
      Called when a Player double click in the inventory
      Parameters:
      player - the player who clicked
      slot - the slot number
      Returns:
      true if the click hasn't been cancelled, false otherwise
    • callClickEvent

      default void callClickEvent(@NotNull @NotNull Player player, Inventory inventory, int slot, @NotNull @NotNull ClickType clickType, @NotNull @NotNull ItemStack clicked, @NotNull @NotNull ItemStack cursor)