java.lang.Object
org.cloudburstmc.server.inventory.transaction.action.InventoryAction
Direct Known Subclasses:
CraftingTakeResultAction, CraftingTransferMaterialAction, CreativeInventoryAction, DropItemAction, SlotChangeAction

public abstract class InventoryAction extends Object
Author:
CreeperFace
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.cloudburstmc.api.item.ItemStack
     
    protected org.cloudburstmc.api.item.ItemStack
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    InventoryAction​(org.cloudburstmc.api.item.ItemStack sourceItem, org.cloudburstmc.api.item.ItemStack targetItem)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    execute​(CloudPlayer source)
    Performs actions needed to complete the inventory-action server-side.
    long
     
    org.cloudburstmc.api.item.ItemStack
    Returns the item that was present before the action took place.
    org.cloudburstmc.api.item.ItemStack
    Returns the item that the action attempted to replace the source item with.
    abstract boolean
    isValid​(CloudPlayer source)
    Returns whether this action is currently valid.
    void
    Called when the action is added to the specified InventoryTransaction.
    abstract void
    Performs additional actions when this inventory-action did not complete successfully.
    abstract void
    Performs additional actions when this inventory-action completed successfully.
    boolean
    Called by inventory transactions before any actions are processed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sourceItem

      protected org.cloudburstmc.api.item.ItemStack sourceItem
    • targetItem

      protected org.cloudburstmc.api.item.ItemStack targetItem
  • Constructor Details

    • InventoryAction

      public InventoryAction(org.cloudburstmc.api.item.ItemStack sourceItem, org.cloudburstmc.api.item.ItemStack targetItem)
  • Method Details

    • getCreationTime

      public long getCreationTime()
    • getSourceItem

      public org.cloudburstmc.api.item.ItemStack getSourceItem()
      Returns the item that was present before the action took place.
      Returns:
      source item
    • getTargetItem

      public org.cloudburstmc.api.item.ItemStack getTargetItem()
      Returns the item that the action attempted to replace the source item with.
      Returns:
      target item
    • onPreExecute

      public boolean onPreExecute(CloudPlayer source)
      Called by inventory transactions before any actions are processed. If this returns false, the transaction will be cancelled.
      Parameters:
      source - player
      Returns:
      cancelled
    • isValid

      public abstract boolean isValid(CloudPlayer source)
      Returns whether this action is currently valid. This should perform any necessary sanity checks.
      Parameters:
      source - player
      Returns:
      valid
    • onAddToTransaction

      public void onAddToTransaction(InventoryTransaction transaction)
      Called when the action is added to the specified InventoryTransaction.
      Parameters:
      transaction - to add
    • execute

      public abstract boolean execute(CloudPlayer source)
      Performs actions needed to complete the inventory-action server-side. Returns if it was successful. Will return false if plugins cancelled events. This will only be called if the transaction which it is part of is considered valid.
      Parameters:
      source - player
      Returns:
      successfully executed
    • onExecuteSuccess

      public abstract void onExecuteSuccess(CloudPlayer source)
      Performs additional actions when this inventory-action completed successfully.
      Parameters:
      source - player
    • onExecuteFail

      public abstract void onExecuteFail(CloudPlayer source)
      Performs additional actions when this inventory-action did not complete successfully.
      Parameters:
      source - player