Package xyz.xenondevs.invui.inventory
Class ObscuredInventory
java.lang.Object
xyz.xenondevs.invui.inventory.Inventory
xyz.xenondevs.invui.inventory.ObscuredInventory
-
Constructor Summary
ConstructorsConstructorDescriptionObscuredInventory(@NotNull Inventory inventory, @NotNull IntPredicate isObscured) Constructs a newObscuredInventory. -
Method Summary
Modifier and TypeMethodDescriptionvoidcallPostUpdateEvent(@Nullable UpdateReason updateReason, int slot, @Nullable org.bukkit.inventory.ItemStack previousItemStack, @Nullable org.bukkit.inventory.ItemStack newItemStack) Creates anItemPostUpdateEventand calls theInventory.postUpdateHandlerto handle it.callPreUpdateEvent(@Nullable UpdateReason updateReason, int slot, @Nullable org.bukkit.inventory.ItemStack previousItemStack, @Nullable org.bukkit.inventory.ItemStack newItemStack) Creates anItemPreUpdateEventand calls theInventory.preUpdateHandlerto handle it.intGets the priority for click actions in aGui, such as shift clicking or cursor collection with multipleVirtualInventories.@Nullable org.bukkit.inventory.ItemStackgetItem(int slot) Gets a clone of theItemStackon that slot.@Nullable org.bukkit.inventory.ItemStack @NotNull []getItems()Gets a copy of the contents of thisInventory.intgetMaxSlotStackSize(int slot) Gets the maximum stack size for a specific slot while ignoring max stack size of theItemStackon it.int @NotNull []Gets the array of max stack sizes for thisInventory.intgetSize()Gets the size of thisInventory.@Nullable org.bukkit.inventory.ItemStackgetUnsafeItem(int slot) Gets theItemStackon that slot.@Nullable org.bukkit.inventory.ItemStack @NotNull []Gets theItemStacksthisInventorycontains.booleanWhether thisInventoryhas any event handlers.voidprotected voidsetCloneBackingItem(int slot, @Nullable org.bukkit.inventory.ItemStack itemStack) Clones the givenItemStackand sets in the backing array of thisInventory.protected voidsetDirectBackingItem(int slot, @Nullable org.bukkit.inventory.ItemStack itemStack) Sets theItemStackin the backing array of thisInventorywithout explicitly cloning it.voidsetGuiPriority(int guiPriority) Sets the priority for click actions in aGui, such as shift-clicking or cursor collection with multipleVirtualInventories.voidsetPostUpdateHandler(@Nullable Consumer<@NotNull ItemPostUpdateEvent> inventoryUpdatedHandler) Sets a handler which is called every time after something has been updated in theInventory.voidsetPreUpdateHandler(@Nullable Consumer<@NotNull ItemPreUpdateEvent> preUpdateHandler) Sets a handler which is called every time something gets updated in theInventory.Methods inherited from class xyz.xenondevs.invui.inventory.Inventory
addItem, addItemAmount, addWindow, canHold, canHold, collectSimilar, collectSimilar, contains, containsSimilar, count, countSimilar, forceSetItem, getItemAmount, getMaxSlotStackSize, getMaxSlotStackSize, getMaxStackSize, getMaxStackSize, getMaxStackSize, getPostUpdateHandler, getPreUpdateHandler, getWindows, hasEmptySlot, hasItem, isEmpty, isFull, isSynced, modifyItem, putItem, removeFirst, removeFirstSimilar, removeIf, removeSimilar, removeWindow, replaceItem, setItem, setItemAmount, setItemSilently, simulateAdd, simulateAdd, simulateMultiAdd, simulateSingleAdd
-
Constructor Details
-
ObscuredInventory
public ObscuredInventory(@NotNull @NotNull Inventory inventory, @NotNull @NotNull IntPredicate isObscured) Constructs a newObscuredInventory.- Parameters:
inventory- TheInventoryto delegate to.isObscured- AIntPredicatethat returns true for slots that should be hidden.
-
-
Method Details
-
getSize
public int getSize()Description copied from class:InventoryGets the size of thisInventory. -
getMaxStackSizes
public int @NotNull [] getMaxStackSizes()Description copied from class:InventoryGets the array of max stack sizes for thisInventory.- Specified by:
getMaxStackSizesin classInventory- Returns:
- The array defining the max stack sizes for this
Inventory
-
getMaxSlotStackSize
public int getMaxSlotStackSize(int slot) Description copied from class:InventoryGets the maximum stack size for a specific slot while ignoring max stack size of theItemStackon it.- Specified by:
getMaxSlotStackSizein classInventory- Parameters:
slot- The slot- Returns:
- The maximum stack size on that slo
-
getItems
@Nullable public @Nullable org.bukkit.inventory.ItemStack @NotNull [] getItems()Description copied from class:InventoryGets a copy of the contents of thisInventory.It is guaranteed that this method will never return an air / empty item stack. Those are always represented by null.
-
getUnsafeItems
@Nullable public @Nullable org.bukkit.inventory.ItemStack @NotNull [] getUnsafeItems()Description copied from class:InventoryGets theItemStacksthisInventorycontains. Depending on the implementation, this method may return a copy, a deep copy, or the actual backing item stack array. Modifying the returned array might or might not reflect in thisInventory.It is guaranteed that this method will never return an air / empty item stack. Those are always represented by null.
- Specified by:
getUnsafeItemsin classInventory- Returns:
- The
ItemStacksthisInventorycontains.
-
getItem
@Nullable public @Nullable org.bukkit.inventory.ItemStack getItem(int slot) Description copied from class:InventoryGets a clone of theItemStackon that slot.It is guaranteed that this method will never return an air / empty item stack. Those are always represented by null.
-
getUnsafeItem
@Nullable public @Nullable org.bukkit.inventory.ItemStack getUnsafeItem(int slot) Description copied from class:InventoryGets theItemStackon that slot. Depending on the implementation, this method may a copy of or the actual backingItemStack.It is guaranteed that this method will never return an air / empty item stack. Those are always represented by null.
- Specified by:
getUnsafeItemin classInventory- Parameters:
slot- The slot- Returns:
- The
ItemStackon the given slot.
-
setCloneBackingItem
protected void setCloneBackingItem(int slot, @Nullable @Nullable org.bukkit.inventory.ItemStack itemStack) Description copied from class:InventoryClones the givenItemStackand sets in the backing array of thisInventory.This method should never be invoked with an air / empty item stack. Those should always be represented by null.
- Specified by:
setCloneBackingItemin classInventory- Parameters:
slot- The slotitemStack- TheItemStackto be set
-
setDirectBackingItem
protected void setDirectBackingItem(int slot, @Nullable @Nullable org.bukkit.inventory.ItemStack itemStack) Description copied from class:InventorySets theItemStackin the backing array of thisInventorywithout explicitly cloning it. Depending on the implementation, theItemStackmight still be cloned.This method should never be invoked with an air / empty item stack. Those should always be represented by null.
- Specified by:
setDirectBackingItemin classInventory- Parameters:
slot- The slotitemStack- TheItemStackto be set
-
notifyWindows
public void notifyWindows()Description copied from class:InventoryNotifies allWindows displaying thisInventoryto update their representativeItemStacks. This method should only be called manually in very specific cases like when theItemMetaof anItemStackin this inventory has changed.- Overrides:
notifyWindowsin classInventory
-
callPreUpdateEvent
public ItemPreUpdateEvent callPreUpdateEvent(@Nullable @Nullable UpdateReason updateReason, int slot, @Nullable @Nullable org.bukkit.inventory.ItemStack previousItemStack, @Nullable @Nullable org.bukkit.inventory.ItemStack newItemStack) Description copied from class:InventoryCreates anItemPreUpdateEventand calls theInventory.preUpdateHandlerto handle it.- Overrides:
callPreUpdateEventin classInventory- Parameters:
updateReason- TheUpdateReason.slot- The slot of the affectedItemStack.previousItemStack- TheItemStackthat was previously on that slot.newItemStack- TheItemStackthat will be on that slot.- Returns:
- The
ItemPreUpdateEventafter it has been handled by theInventory.preUpdateHandler.
-
callPostUpdateEvent
public void callPostUpdateEvent(@Nullable @Nullable UpdateReason updateReason, int slot, @Nullable @Nullable org.bukkit.inventory.ItemStack previousItemStack, @Nullable @Nullable org.bukkit.inventory.ItemStack newItemStack) Description copied from class:InventoryCreates anItemPostUpdateEventand calls theInventory.postUpdateHandlerto handle it.- Overrides:
callPostUpdateEventin classInventory- Parameters:
updateReason- TheUpdateReason.slot- The slot of the affectedItemStack.previousItemStack- TheItemStackthat was on that slot previously.newItemStack- TheItemStackthat is on that slot now.
-
hasEventHandlers
public boolean hasEventHandlers()Description copied from class:InventoryWhether thisInventoryhas any event handlers.- Overrides:
hasEventHandlersin classInventory- Returns:
- `true` if this
Inventoryhas a pre- or post-update handler.
-
setPostUpdateHandler
public void setPostUpdateHandler(@Nullable @Nullable Consumer<@NotNull ItemPostUpdateEvent> inventoryUpdatedHandler) Description copied from class:InventorySets a handler which is called every time after something has been updated in theInventory.- Overrides:
setPostUpdateHandlerin classInventory- Parameters:
inventoryUpdatedHandler- The new handler
-
setPreUpdateHandler
public void setPreUpdateHandler(@Nullable @Nullable Consumer<@NotNull ItemPreUpdateEvent> preUpdateHandler) Description copied from class:InventorySets a handler which is called every time something gets updated in theInventory.- Overrides:
setPreUpdateHandlerin classInventory- Parameters:
preUpdateHandler- The new item update handler
-
getGuiPriority
public int getGuiPriority()Description copied from class:InventoryGets the priority for click actions in aGui, such as shift clicking or cursor collection with multipleVirtualInventories.- Overrides:
getGuiPriorityin classInventory- Returns:
- The priority for click actions,
VirtualInventorieswith a higher priority get prioritized.
-
setGuiPriority
public void setGuiPriority(int guiPriority) Description copied from class:InventorySets the priority for click actions in aGui, such as shift-clicking or cursor collection with multipleVirtualInventories.- Overrides:
setGuiPriorityin classInventory- Parameters:
guiPriority- The priority for click actions,VirtualInventorieswith a higher priority get prioritized.
-