Class ItemPostUpdateEvent
java.lang.Object
xyz.xenondevs.invui.inventory.event.ItemPostUpdateEvent
An event that is called after the
Inventory
has been updated.-
Field Summary
-
Constructor Summary
ConstructorDescriptionItemPostUpdateEvent
(@NotNull Inventory inventory, int slot, @Nullable UpdateReason updateReason, @Nullable org.bukkit.inventory.ItemStack previousItem, @Nullable org.bukkit.inventory.ItemStack newItem) Creates a newItemPreUpdateEvent
. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the amount of items that have been added.@NotNull Inventory
Gets theInventory
where this action takes place.@Nullable org.bukkit.inventory.ItemStack
Gets clone of the newItemStack
that will be there if the event isn't cancelled.@Nullable org.bukkit.inventory.ItemStack
Gets a clone of theItemStack
that was there previously.int
Gets the amount of items that have been removed.int
getSlot()
Gets the slot that is affected.@Nullable UpdateReason
Gets theUpdateReason
for the calling of this event.boolean
isAdd()
Gets if the action resulted in items being added to theInventory
.boolean
isRemove()
Gets if the action resulted in items being removed from theInventory
.boolean
isSwap()
Gets if the type of theItemStack
has changed.
-
Field Details
-
Constructor Details
-
ItemPostUpdateEvent
public ItemPostUpdateEvent(@NotNull @NotNull Inventory inventory, int slot, @Nullable @Nullable UpdateReason updateReason, @Nullable @Nullable org.bukkit.inventory.ItemStack previousItem, @Nullable @Nullable org.bukkit.inventory.ItemStack newItem) Creates a newItemPreUpdateEvent
.- Parameters:
inventory
- TheInventory
where this action takes place.slot
- The slot that is affectedupdateReason
- TheUpdateReason
for the calling of this event. This will probably be aPlayerUpdateReason
in most cases but can be a custom one if you called the methods in theInventory
yourself. if it wasn't aPlayer
previousItem
- TheItemStack
that was on that slot previouslynewItem
- TheItemStack
that is on that slot now
-
-
Method Details
-
getInventory
Gets theInventory
where this action takes place.- Returns:
- The
Inventory
-
getUpdateReason
Gets theUpdateReason
for the calling of this event.- Returns:
- The reason why this event was called. Probably a
PlayerUpdateReason
in most cases.
-
getPreviousItem
@Nullable public @Nullable org.bukkit.inventory.ItemStack getPreviousItem()Gets a clone of theItemStack
that was there previously.- Returns:
- The
ItemStack
-
getNewItem
@Nullable public @Nullable org.bukkit.inventory.ItemStack getNewItem()Gets clone of the newItemStack
that will be there if the event isn't cancelled.- Returns:
- The new
ItemStack
-
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 theInventory
.- Returns:
- If items were added to the
Inventory
-
isRemove
public boolean isRemove()Gets if the action resulted in items being removed from theInventory
.- Returns:
- If items were removed from the
Inventory
-
isSwap
public boolean isSwap()Gets if the type of theItemStack
has changed. This does not account for anItemStack
turning null or being null previously,isRemove()
andisAdd()
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
- 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
-