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
ConstructorsConstructorDescriptionPlayerSwapItemEvent(@NotNull Player player, @NotNull ItemStack mainHandItem, @NotNull ItemStack offHandItem) -
Method Summary
Modifier and TypeMethodDescription@NotNull ItemStackGets the item which will be in player main hand after the event.@NotNull ItemStackGets the item which will be in player off hand after the event.@NotNull PlayerGets the player.booleanGets if theEventshould be cancelled or not.voidsetCancelled(boolean cancel) Marks theEventas cancelled or not.voidsetMainHandItem(@NotNull ItemStack mainHandItem) Changes the item which will be in the player main hand.voidsetOffHandItem(@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, waitMethods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstanceMethods 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:CancellableEventGets if theEventshould be cancelled or not.- Specified by:
isCancelledin interfaceCancellableEvent- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEventMarks theEventas cancelled or not.- Specified by:
setCancelledin interfaceCancellableEvent- Parameters:
cancel- true if the event should be cancelled, false otherwise
-
getPlayer
Description copied from interface:PlayerEventGets the player.- Specified by:
getPlayerin interfacePlayerEvent- Returns:
- the player
-