Class InventoryUpdatedEvent

java.lang.Object
de.studiocode.invui.virtualinventory.event.ItemUpdateEvent
de.studiocode.invui.virtualinventory.event.InventoryUpdatedEvent

public class InventoryUpdatedEvent extends ItemUpdateEvent
An event that is called after the VirtualInventory has been updated.
  • Constructor Details

    • InventoryUpdatedEvent

      public InventoryUpdatedEvent(@NotNull @NotNull VirtualInventory virtualInventory, int slot, @Nullable @Nullable UpdateReason updateReason, @Nullable @Nullable org.bukkit.inventory.ItemStack previousItemStack, @Nullable @Nullable org.bukkit.inventory.ItemStack newItemStack)
      Creates a new ItemUpdateEvent.
      Parameters:
      virtualInventory - The VirtualInventory where this action takes place.
      updateReason - The UpdateReason for the calling of this event. This will probably be a PlayerUpdateReason in most cases but can be a custom one if you called the methods in the VirtualInventory yourself. if it wasn't a Player
      slot - The slot that is affected
      previousItemStack - The ItemStack that was on that slot previously
      newItemStack - The ItemStack that is on that slot now
  • Method Details

    • getVirtualInventory

      public VirtualInventory getVirtualInventory()
      Gets the VirtualInventory where this action takes place.
      Returns:
      The VirtualInventory
    • getUpdateReason

      public UpdateReason getUpdateReason()
      Gets the UpdateReason for the calling of this event.
      Returns:
      The reason why this event was called. Probably a PlayerUpdateReason in most cases.
    • getPreviousItemStack

      public org.bukkit.inventory.ItemStack getPreviousItemStack()
      Gets the ItemStack that was there previously.
      Returns:
      The ItemStack
    • getNewItemStack

      public org.bukkit.inventory.ItemStack getNewItemStack()
      The new ItemStack that will be there if the event isn't cancelled.
      Returns:
      The new ItemStack
    • setNewItemStack

      public void setNewItemStack(@Nullable @Nullable org.bukkit.inventory.ItemStack newItemStack)
      Change the ItemStack that will appear in the VirtualInventory to a different one.
      Parameters:
      newItemStack - The ItemStack to appear in the VirtualInventory if the ItemUpdateEvent is not cancelled.
    • getSlot

      public int getSlot()
      Gets the slot that is affected.
      Returns:
      The slot
    • isAdd

      public boolean isAdd()
      Gets if the action resulted in items being added to the VirtualInventory.
      Returns:
      If items were added to the VirtualInventory
    • isRemove

      public boolean isRemove()
      Gets if the action resulted in items being removed from the VirtualInventory.
      Returns:
      If items were removed from the VirtualInventory
    • isSwap

      public boolean isSwap()
      Gets if the type of the ItemStack has changed. This does not account for an ItemStack turning null or being null previously, isRemove() and isAdd() should be used for that.
      Returns:
      If the type of the ItemStack has changed
    • getRemovedAmount

      public int getRemovedAmount()
      Gets the amount of items that have been removed.
      Returns:
      The amount of items that have been removed
      Throws:
      IllegalStateException - when isRemove() is false
    • getAddedAmount

      public int getAddedAmount()
      Gets the amount of items that have been added.
      Returns:
      The amount of items that have been added
      Throws:
      IllegalStateException - when isAdd() is false