Class PrepareHopperTransferEvent

java.lang.Object
org.bukkit.event.Event
io.papermc.paper.event.inventory.PrepareHopperTransferEvent

@NullMarked public class PrepareHopperTransferEvent extends Event
Called when a hopper or hopper minecart is about to choose an item to move, before any InventoryMoveItemEvent.

The hopper treats disallowed slots of the source as if they do not exist, so a source with items only in disallowed slots is treated as empty.

  • Field Details

    • disallowedSlots

      protected long disallowedSlots
  • Constructor Details

    • PrepareHopperTransferEvent

      @Internal public PrepareHopperTransferEvent(Inventory source, Inventory destination, boolean didSourceInitiate)
  • Method Details

    • getSource

      public Inventory getSource()
      Gets the Inventory that items are being taken from
      Returns:
      Inventory that items are being taken from
    • getDestination

      public Inventory getDestination()
      Gets the Inventory that items are being put into
      Returns:
      Inventory that items are being put into
    • getInitiator

      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
    • isSlotAllowed

      public boolean isSlotAllowed(int slot)
      Gets if the hopper is allowed to take items from a slot of getSource().
      Parameters:
      slot - the slot
      Returns:
      true if the slot is allowed
    • setSlotAllowed

      public void setSlotAllowed(int slot, boolean allowed)
      Sets if the hopper is allowed to take items from a slot of getSource().
      Parameters:
      slot - the slot
      allowed - whether the slot is allowed
    • getHandlers

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

      public static HandlerList getHandlerList()