Class InventoryMoveItemEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.inventory.InventoryMoveItemEvent
All Implemented Interfaces:
Cancellable

public class InventoryMoveItemEvent extends Event implements Cancellable
Called when some entity or block (e.g. hopper) tries to move items directly from one inventory to another.

When this event is called, the initiator may already have removed the item from the source inventory and is ready to move it into the destination inventory.

If this event is cancelled, the items will be returned to the source inventory, if needed.

If this event is not cancelled, the initiator will try to put the ItemStack into the destination inventory. If this is not possible and the ItemStack has not been modified, the source inventory slot will be restored to its former state. Otherwise any additional items will be discarded.

  • Constructor Details

    • InventoryMoveItemEvent

      public InventoryMoveItemEvent(@NotNull Inventory sourceInventory, @NotNull ItemStack itemStack, @NotNull Inventory destinationInventory, boolean didSourceInitiate)
  • Method Details

    • getSource

      @NotNull public Inventory getSource()
      Gets the Inventory that the ItemStack is being taken from
      Returns:
      Inventory that the ItemStack is being taken from
    • getItem

      @NotNull public ItemStack getItem()
      Gets the ItemStack being moved; if modified, the original item will not be removed from the source inventory.
      Returns:
      ItemStack
    • setItem

      public void setItem(@NotNull ItemStack itemStack)
      Sets the ItemStack being moved; if this is different from the original ItemStack, the original item will not be removed from the source inventory.
      Parameters:
      itemStack - The ItemStack
    • getDestination

      @NotNull public Inventory getDestination()
      Gets the Inventory that the ItemStack is being put into
      Returns:
      Inventory that the ItemStack is being put into
    • getInitiator

      @NotNull public Inventory getInitiator()
      Gets the Inventory that initiated the transfer. This will always be either the destination or source Inventory.
      Returns:
      Inventory that initiated the transfer
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if this event is cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - true if you wish to cancel this event
    • getHandlers

      @NotNull public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      @NotNull public static HandlerList getHandlerList()