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(@NotNull @NotNull AbstractInventory inventory, @NotNull @NotNull Player player, @NotNull @NotNull Click click)
  • 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
    • getClick

      @NotNull public @NotNull Click getClick()
      Gets the player's click.
    • setClick

      public void setClick(@NotNull @NotNull Click click)
      Sets the player's click.
    • getSlot

      public int getSlot()
      Returns the clicked slot. This is only for convenience and may return -999 (a meaningless number), as some clicks don't have a relevant slot (drag clicks and some drops). See Click.slot() for details.
    • getClickedItem

      @NotNull public @NotNull ItemStack getClickedItem()
      Returns the clicked item. Some clicks involve more than a single item, like drops or clicks outside the inventory menu; in these cases, the cursor is returned.
    • 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

      @NotNull public @NotNull AbstractInventory getInventory()
      Description copied from interface: InventoryEvent
      Gets the inventory that was clicked.
      Specified by:
      getInventory in interface InventoryEvent