Class PlayerInventorySlotChangeEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
io.papermc.paper.event.player.PlayerInventorySlotChangeEvent

@NullMarked public class PlayerInventorySlotChangeEvent extends PlayerEvent
Called when a slot contents change in a player's inventory.
  • Constructor Details

    • PlayerInventorySlotChangeEvent

      public PlayerInventorySlotChangeEvent(Player player, int rawSlot, ItemStack oldItemStack, ItemStack newItemStack)
  • Method Details

    • getRawSlot

      public int getRawSlot()
      The raw slot number that was changed.
      Returns:
      The raw slot number.
    • getSlot

      public int getSlot()
      The slot number that was changed, ready for passing to Inventory.getItem(int). Note that there may be two slots with the same slot number, since a view links two different inventories.

      If no inventory is opened, internal crafting view is used for conversion.

      Returns:
      The slot number.
    • getOldItemStack

      public ItemStack getOldItemStack()
      Clone of ItemStack that was in the slot before the change.
      Returns:
      The old ItemStack in the slot.
    • getNewItemStack

      public ItemStack getNewItemStack()
      Clone of ItemStack that is in the slot after the change.
      Returns:
      The new ItemStack in the slot.
    • shouldTriggerAdvancements

      public boolean shouldTriggerAdvancements()
      Gets whether the slot change advancements will be triggered.
      Returns:
      Whether the slot change advancements will be triggered.
    • setShouldTriggerAdvancements

      public void setShouldTriggerAdvancements(boolean triggerAdvancements)
      Sets whether the slot change advancements will be triggered.
      Parameters:
      triggerAdvancements - Whether the slot change advancements will be triggered.
    • getHandlers

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

      public static HandlerList getHandlerList()