Class InventoryTransaction
java.lang.Object
org.cloudburstmc.server.inventory.transaction.InventoryTransaction
- Direct Known Subclasses:
CraftingTransaction,ItemStackTransaction
- Author:
- CreeperFace
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<InventoryAction>protected booleanprotected Set<org.cloudburstmc.api.inventory.Inventory>protected CloudPlayer -
Constructor Summary
ConstructorsConstructorDescriptionInventoryTransaction(CloudPlayer source, List<InventoryAction> actions)InventoryTransaction(CloudPlayer source, List<InventoryAction> actions, boolean init) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAction(InventoryAction action)voidaddInventory(org.cloudburstmc.api.inventory.Inventory inventory)This method should not be used by plugins, it's used to add tracked inventories for InventoryActions involving inventories.protected booleanbooleanbooleanexecute()longSet<org.cloudburstmc.api.inventory.Inventory>booleanprotected voidinit(CloudPlayer source, List<InventoryAction> actions)protected booleanmatchItems(List<org.cloudburstmc.api.item.ItemStack> needItems, List<org.cloudburstmc.api.item.ItemStack> haveItems)protected voidprotected booleanIterates over SlotChangeActions in this transaction and compacts any which refer to the same inventorySlot in the same inventory so they can be correctly handled.
-
Field Details
-
hasExecuted
protected boolean hasExecuted -
source
-
inventories
-
actions
-
-
Constructor Details
-
InventoryTransaction
-
InventoryTransaction
-
-
Method Details
-
init
-
getSource
-
getCreationTime
public long getCreationTime() -
getInventories
-
getActions
-
addAction
-
addInventory
public void addInventory(org.cloudburstmc.api.inventory.Inventory inventory)This method should not be used by plugins, it's used to add tracked inventories for InventoryActions involving inventories.- Parameters:
inventory- to add
-
matchItems
-
sendInventories
protected void sendInventories() -
squashDuplicateSlotChanges
protected boolean squashDuplicateSlotChanges()Iterates over SlotChangeActions in this transaction and compacts any which refer to the same inventorySlot in the same inventory so they can be correctly handled.Under normal circumstances, the same inventorySlot would never be changed more than once in a single transaction. However, due to the way things like the crafting grid are "implemented" in MCPE 1.2 (a.k.a. hacked-in), we may get multiple inventorySlot changes referring to the same inventorySlot in a single transaction. These multiples are not even guaranteed to be in the correct order (inventorySlot splitting in the crafting grid for example, causes the actions to be sent in the wrong order), so this method also tries to chain them into order.
- Returns:
- successful
-
canExecute
public boolean canExecute() -
callExecuteEvent
protected boolean callExecuteEvent() -
execute
public boolean execute() -
hasExecuted
public boolean hasExecuted()
-