java.lang.Object
org.cloudburstmc.server.inventory.transaction.action.InventoryAction
org.cloudburstmc.server.inventory.transaction.action.SlotChangeAction

public class SlotChangeAction extends InventoryAction
Author:
CreeperFace
  • Field Details

    • inventory

      protected org.cloudburstmc.api.inventory.Inventory inventory
  • Constructor Details

    • SlotChangeAction

      public SlotChangeAction(org.cloudburstmc.api.inventory.Inventory inventory, int inventorySlot, org.cloudburstmc.api.item.ItemStack sourceItem, org.cloudburstmc.api.item.ItemStack targetItem)
  • Method Details

    • getInventory

      public org.cloudburstmc.api.inventory.Inventory getInventory()
      Returns the inventory involved in this action.
      Returns:
      inventory
    • getSlot

      public int getSlot()
      Returns the inventorySlot in the inventory which this action modified.
      Returns:
      slot
    • isValid

      public boolean isValid(CloudPlayer source)
      Checks if the item in the inventory at the specified inventorySlot is the same as this action's source item.
      Specified by:
      isValid in class InventoryAction
      Parameters:
      source - player
      Returns:
      valid
    • execute

      public boolean execute(CloudPlayer source)
      Sets the item into the target inventory.
      Specified by:
      execute in class InventoryAction
      Parameters:
      source - player
      Returns:
      successfully executed
    • onExecuteSuccess

      public void onExecuteSuccess(CloudPlayer source)
      Sends inventorySlot changes to other viewers of the inventory. This will not send any change back to the source Player.
      Specified by:
      onExecuteSuccess in class InventoryAction
      Parameters:
      source - player
    • onExecuteFail

      public void onExecuteFail(CloudPlayer source)
      Sends the original inventorySlot contents to the source player to revert the action.
      Specified by:
      onExecuteFail in class InventoryAction
      Parameters:
      source - player
    • onAddToTransaction

      public void onAddToTransaction(InventoryTransaction transaction)
      Description copied from class: InventoryAction
      Called when the action is added to the specified InventoryTransaction.
      Overrides:
      onAddToTransaction in class InventoryAction
      Parameters:
      transaction - to add