Class InventoryTransaction

java.lang.Object
org.cloudburstmc.server.inventory.transaction.InventoryTransaction
Direct Known Subclasses:
CraftingTransaction, ItemStackTransaction

public class InventoryTransaction extends Object
Author:
CreeperFace
  • Field Details

    • hasExecuted

      protected boolean hasExecuted
    • source

      protected CloudPlayer source
    • inventories

      protected Set<org.cloudburstmc.api.inventory.Inventory> inventories
    • actions

      protected List<InventoryAction> actions
  • Constructor Details

  • Method Details

    • init

      protected void init(CloudPlayer source, List<InventoryAction> actions)
    • getSource

      public CloudPlayer getSource()
    • getCreationTime

      public long getCreationTime()
    • getInventories

      public Set<org.cloudburstmc.api.inventory.Inventory> getInventories()
    • getActions

      public List<InventoryAction> getActions()
    • addAction

      public void addAction(InventoryAction action)
    • 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

      protected boolean matchItems(List<org.cloudburstmc.api.item.ItemStack> needItems, List<org.cloudburstmc.api.item.ItemStack> haveItems)
    • 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()