Class PlayerSwapItemEvent

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

public class PlayerSwapItemEvent extends Object implements PlayerInstanceEvent, CancellableEvent
Called when a player is trying to swap his main and off hand item.
  • Constructor Details

    • PlayerSwapItemEvent

      public PlayerSwapItemEvent(@NotNull @NotNull Player player, @NotNull @NotNull ItemStack mainHandItem, @NotNull @NotNull ItemStack offHandItem)
  • Method Details

    • getMainHandItem

      @NotNull public @NotNull ItemStack getMainHandItem()
      Gets the item which will be in player main hand after the event.
      Returns:
      the item in main hand
    • setMainHandItem

      public void setMainHandItem(@NotNull @NotNull ItemStack mainHandItem)
      Changes the item which will be in the player main hand.
      Parameters:
      mainHandItem - the main hand item
    • getOffHandItem

      @NotNull public @NotNull ItemStack getOffHandItem()
      Gets the item which will be in player off hand after the event.
      Returns:
      the item in off hand
    • setOffHandItem

      public void setOffHandItem(@NotNull @NotNull ItemStack offHandItem)
      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 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
    • getPlayer

      @NotNull public @NotNull Player getPlayer()
      Description copied from interface: PlayerEvent
      Gets the player.
      Specified by:
      getPlayer in interface PlayerEvent
      Returns:
      the player