Class InventoryPreClickEvent

java.lang.Object
net.minestom.server.event.inventory.InventoryPreClickEvent
All Implemented Interfaces:
Event, CancellableEvent, EntityEvent, EntityInstanceEvent, InstanceEvent, InventoryEvent, PlayerEvent, PlayerInstanceEvent

public class InventoryPreClickEvent extends Object implements InventoryEvent, PlayerInstanceEvent, CancellableEvent
Called before InventoryClickEvent, used to potentially cancel the click.
  • Constructor Details

    • InventoryPreClickEvent

      public InventoryPreClickEvent(@Nullable @Nullable Inventory inventory, @NotNull @NotNull Player player, int slot, @NotNull @NotNull ClickType clickType, @NotNull @NotNull ItemStack clicked, @NotNull @NotNull ItemStack cursor)
  • Method Details

    • getPlayer

      @NotNull public @NotNull Player getPlayer()
      Gets the player who is trying to click on the inventory.
      Specified by:
      getPlayer in interface PlayerEvent
      Returns:
      the player who clicked
    • getSlot

      public int getSlot()
      Gets the clicked slot number.
      Returns:
      the clicked slot number
    • getClickType

      @NotNull public @NotNull ClickType getClickType()
      Gets the click type.
      Returns:
      the click type
    • getClickedItem

      @NotNull public @NotNull ItemStack getClickedItem()
      Gets the item who have been clicked.
      Returns:
      the clicked item
    • setClickedItem

      public void setClickedItem(@NotNull @NotNull ItemStack clickedItem)
      Changes the clicked item.
      Parameters:
      clickedItem - the clicked item
    • getCursorItem

      @NotNull public @NotNull ItemStack getCursorItem()
      Gets the item who was in the player cursor.
      Returns:
      the cursor item
    • setCursorItem

      public void setCursorItem(@NotNull @NotNull ItemStack cursorItem)
      Changes the cursor item.
      Parameters:
      cursorItem - the cursor item
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: CancellableEvent
      Gets if the Event should be cancelled or not.
      Specified by:
      isCancelled in interface CancellableEvent
      Returns:
      true if the event should be cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: CancellableEvent
      Marks the Event as cancelled or not.
      Specified by:
      setCancelled in interface CancellableEvent
      Parameters:
      cancel - true if the event should be cancelled, false otherwise
    • getInventory

      @Nullable public @Nullable Inventory getInventory()
      Description copied from interface: InventoryEvent
      Gets the inventory.
      Specified by:
      getInventory in interface InventoryEvent
      Returns:
      the inventory, null if this is a player's inventory