Class SlotChangeAction

java.lang.Object
cn.nukkit.inventory.transaction.action.InventoryAction
cn.nukkit.inventory.transaction.action.SlotChangeAction

public class SlotChangeAction extends InventoryAction
Author:
CreeperFace
  • Field Details

  • Constructor Details

    • SlotChangeAction

      public SlotChangeAction(Inventory inventory, int inventorySlot, Item sourceItem, Item targetItem)
  • Method Details

    • getInventory

      public 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(Player 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

      @PowerNukkitXDifference(info="Use setItemByPlayer", since="1.19.50-r3") public boolean execute(Player source)
      Sets the item into the target inventory.
      Specified by:
      execute in class InventoryAction
      Parameters:
      source - player
      Returns:
      successfully executed
    • onExecuteSuccess

      public void onExecuteSuccess(Player 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(Player 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
    • toString

      public String toString()
      Overrides:
      toString in class InventoryAction