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 Summary
ConstructorsConstructorDescriptionInventoryPreClickEvent
(@NotNull AbstractInventory inventory, @NotNull Player player, @NotNull Click click) -
Method Summary
Modifier and TypeMethodDescription@NotNull Click
getClick()
Gets the player's click.@NotNull ItemStack
Returns the clicked item.@NotNull AbstractInventory
Gets the inventory that was clicked.@NotNull Player
Gets the player who is trying to click on the inventory.int
getSlot()
Returns the clicked slot.boolean
Gets if theEvent
should be cancelled or not.void
setCancelled
(boolean cancel) Marks theEvent
as cancelled or not.void
Sets the player's click.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstance
Methods inherited from interface net.minestom.server.event.trait.PlayerEvent
getEntity
-
Constructor Details
-
InventoryPreClickEvent
public InventoryPreClickEvent(@NotNull @NotNull AbstractInventory inventory, @NotNull @NotNull Player player, @NotNull @NotNull Click click)
-
-
Method Details
-
getPlayer
Gets the player who is trying to click on the inventory.- Specified by:
getPlayer
in interfacePlayerEvent
- Returns:
- the player who clicked
-
getClick
Gets the player's click. -
setClick
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). SeeClick.slot()
for details. -
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 theEvent
should be cancelled or not.- Specified by:
isCancelled
in interfaceCancellableEvent
- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEvent
Marks theEvent
as cancelled or not.- Specified by:
setCancelled
in interfaceCancellableEvent
- Parameters:
cancel
- true if the event should be cancelled, false otherwise
-
getInventory
Description copied from interface:InventoryEvent
Gets the inventory that was clicked.- Specified by:
getInventory
in interfaceInventoryEvent
-