Class InventoryOpenEvent

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

public class InventoryOpenEvent extends Object implements InventoryEvent, PlayerInstanceEvent, CancellableEvent
Called when a player open an Inventory.

Executed by Player.openInventory(Inventory).

  • Constructor Details

    • InventoryOpenEvent

      public InventoryOpenEvent(@Nullable @Nullable Inventory inventory, @NotNull @NotNull Player player)
  • Method Details

    • getPlayer

      @NotNull public @NotNull Player getPlayer()
      Gets the player who opens the inventory.
      Specified by:
      getPlayer in interface PlayerEvent
      Returns:
      the player who opens the inventory
    • getInventory

      @Nullable public @Nullable Inventory getInventory()
      Gets the inventory to open, this could have been change by the setInventory(Inventory).
      Specified by:
      getInventory in interface InventoryEvent
      Returns:
      the inventory to open, null to just close the current inventory if any
    • setInventory

      public void setInventory(@Nullable @Nullable Inventory inventory)
      Changes the inventory to open.

      To do not open any inventory see setCancelled(boolean).

      Parameters:
      inventory - the inventory to open
    • 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