SlotChangeAction
extends InventoryAction
in package
Represents an action causing a change in an inventory slot.
Table of Contents
- $inventory : Inventory
- $sourceItem : Item
- $targetItem : Item
- $inventorySlot : int
- __construct() : mixed
- execute() : void
- Sets the item into the target inventory.
- getInventory() : Inventory
- Returns the inventory involved in this action.
- getSlot() : int
- Returns the slot in the inventory which this action modified.
- getSourceItem() : Item
- Returns the item that was present before the action took place.
- getTargetItem() : Item
- Returns the item that the action attempted to replace the source item with.
- onAddToTransaction() : void
- Adds this action's target inventory to the transaction's inventory list.
- onPreExecute() : bool
- Called by inventory transactions before any actions are processed. If this returns false, the transaction will be cancelled.
- validate() : void
- Checks if the item in the inventory at the specified slot is the same as this action's source item.
Properties
$inventory
protected
Inventory
$inventory
$sourceItem
protected
Item
$sourceItem
$targetItem
protected
Item
$targetItem
$inventorySlot
private
int
$inventorySlot
Methods
__construct()
public
__construct(Inventory $inventory, int $inventorySlot, Item $sourceItem, Item $targetItem) : mixed
Parameters
Return values
mixed —execute()
Sets the item into the target inventory.
public
execute(Player $source) : void
Parameters
- $source : Player
Return values
void —getInventory()
Returns the inventory involved in this action.
public
getInventory() : Inventory
Return values
Inventory —getSlot()
Returns the slot in the inventory which this action modified.
public
getSlot() : int
Return values
int —getSourceItem()
Returns the item that was present before the action took place.
public
getSourceItem() : Item
Return values
Item —getTargetItem()
Returns the item that the action attempted to replace the source item with.
public
getTargetItem() : Item
Return values
Item —onAddToTransaction()
Adds this action's target inventory to the transaction's inventory list.
public
onAddToTransaction(InventoryTransaction $transaction) : void
Parameters
- $transaction : InventoryTransaction
Return values
void —onPreExecute()
Called by inventory transactions before any actions are processed. If this returns false, the transaction will be cancelled.
public
onPreExecute(Player $source) : bool
Parameters
- $source : Player
Return values
bool —validate()
Checks if the item in the inventory at the specified slot is the same as this action's source item.
public
validate(Player $source) : void
Parameters
- $source : Player