Package net.minestom.server.event.player
Class PlayerSwapItemEvent
java.lang.Object
net.minestom.server.event.player.PlayerSwapItemEvent
- All Implemented Interfaces:
Event
,CancellableEvent
,EntityEvent
,EntityInstanceEvent
,InstanceEvent
,PlayerEvent
,PlayerInstanceEvent
Called when a player is trying to swap his main and off hand item.
-
Constructor Summary
ConstructorDescriptionPlayerSwapItemEvent
(@NotNull Player player, @NotNull ItemStack mainHandItem, @NotNull ItemStack offHandItem) -
Method Summary
Modifier and TypeMethodDescription@NotNull ItemStack
Gets the item which will be in player main hand after the event.@NotNull ItemStack
Gets the item which will be in player off hand after the event.@NotNull Player
Gets the player.boolean
Gets if theEvent
should be cancelled or not.void
setCancelled
(boolean cancel) Marks theEvent
as cancelled or not.void
setMainHandItem
(@NotNull ItemStack mainHandItem) Changes the item which will be in the player main hand.void
setOffHandItem
(@NotNull ItemStack offHandItem) Changes the item which will be in the player off hand.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
-
PlayerSwapItemEvent
-
-
Method Details
-
getMainHandItem
Gets the item which will be in player main hand after the event.- Returns:
- the item in main hand
-
setMainHandItem
Changes the item which will be in the player main hand.- Parameters:
mainHandItem
- the main hand item
-
getOffHandItem
Gets the item which will be in player off hand after the event.- Returns:
- the item in off hand
-
setOffHandItem
Changes the item which will be in the player off hand.- Parameters:
offHandItem
- the off hand 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
-
getPlayer
Description copied from interface:PlayerEvent
Gets the player.- Specified by:
getPlayer
in interfacePlayerEvent
- Returns:
- the player
-