Class InventoryUpdatedEvent
java.lang.Object
de.studiocode.invui.virtualinventory.event.ItemUpdateEvent
de.studiocode.invui.virtualinventory.event.InventoryUpdatedEvent
An event that is called after the
VirtualInventory has been updated.-
Constructor Summary
ConstructorsConstructorDescriptionInventoryUpdatedEvent(@NotNull VirtualInventory virtualInventory, int slot, @Nullable UpdateReason updateReason, @Nullable org.bukkit.inventory.ItemStack previousItemStack, @Nullable org.bukkit.inventory.ItemStack newItemStack) Creates a newItemUpdateEvent. -
Method Summary
Modifier and TypeMethodDescriptionintGets the amount of items that have been added.org.bukkit.inventory.ItemStackThe newItemStackthat will be there if the event isn't cancelled.org.bukkit.inventory.ItemStackGets theItemStackthat was there previously.intGets the amount of items that have been removed.intgetSlot()Gets the slot that is affected.Gets theUpdateReasonfor the calling of this event.Gets theVirtualInventorywhere this action takes place.booleanisAdd()Gets if the action resulted in items being added to theVirtualInventory.booleanisRemove()Gets if the action resulted in items being removed from theVirtualInventory.booleanisSwap()Gets if the type of theItemStackhas changed.voidsetNewItemStack(@Nullable org.bukkit.inventory.ItemStack newItemStack) Change theItemStackthat will appear in theVirtualInventoryto a different one.Methods inherited from class de.studiocode.invui.virtualinventory.event.ItemUpdateEvent
isCancelled, setCancelled
-
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 newItemUpdateEvent.- Parameters:
virtualInventory- TheVirtualInventorywhere this action takes place.updateReason- TheUpdateReasonfor the calling of this event. This will probably be aPlayerUpdateReasonin most cases but can be a custom one if you called the methods in theVirtualInventoryyourself. if it wasn't aPlayerslot- The slot that is affectedpreviousItemStack- TheItemStackthat was on that slot previouslynewItemStack- TheItemStackthat is on that slot now
-
-
Method Details
-
getVirtualInventory
Gets theVirtualInventorywhere this action takes place.- Returns:
- The
VirtualInventory
-
getUpdateReason
Gets theUpdateReasonfor the calling of this event.- Returns:
- The reason why this event was called. Probably a
PlayerUpdateReasonin most cases.
-
getPreviousItemStack
public org.bukkit.inventory.ItemStack getPreviousItemStack()Gets theItemStackthat was there previously.- Returns:
- The
ItemStack
-
getNewItemStack
public org.bukkit.inventory.ItemStack getNewItemStack()The newItemStackthat 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 theItemStackthat will appear in theVirtualInventoryto a different one.- Parameters:
newItemStack- TheItemStackto appear in theVirtualInventoryif theItemUpdateEventis 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 theVirtualInventory.- Returns:
- If items were added to the
VirtualInventory
-
isRemove
public boolean isRemove()Gets if the action resulted in items being removed from theVirtualInventory.- Returns:
- If items were removed from the
VirtualInventory
-
isSwap
public boolean isSwap()Gets if the type of theItemStackhas changed. This does not account for anItemStackturning null or being null previously,isRemove()andisAdd()should be used for that.- Returns:
- If the type of the
ItemStackhas 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- whenisRemove()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- whenisAdd()is false
-