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
-
Method Summary
Modifier and TypeMethodDescription@NotNull ItemStack
Gets the item who have been clicked.@NotNull ClickType
Gets the click type.@NotNull ItemStack
Gets the item who was in the player cursor.@Nullable Inventory
Gets the inventory.@NotNull Player
Gets the player who is trying to click on the inventory.int
getSlot()
Gets the clicked slot number.boolean
Gets if theEvent
should be cancelled or not.void
setCancelled
(boolean cancel) Marks theEvent
as cancelled or not.void
setClickedItem
(@NotNull ItemStack clickedItem) Changes the clicked item.void
setCursorItem
(@NotNull ItemStack cursorItem) Changes the cursor item.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
-
-
Method Details
-
getPlayer
Gets the player who is trying to click on the inventory.- Specified by:
getPlayer
in interfacePlayerEvent
- Returns:
- the player who clicked
-
getSlot
public int getSlot()Gets the clicked slot number.- Returns:
- the clicked slot number
-
getClickType
Gets the click type.- Returns:
- the click type
-
getClickedItem
Gets the item who have been clicked.- Returns:
- the clicked item
-
setClickedItem
Changes the clicked item.- Parameters:
clickedItem
- the clicked item
-
getCursorItem
Gets the item who was in the player cursor.- Returns:
- the cursor item
-
setCursorItem
Changes the cursor item.- Parameters:
cursorItem
- the cursor item
-
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.- Specified by:
getInventory
in interfaceInventoryEvent
- Returns:
- the inventory, null if this is a player's inventory
-