InventoryAction
in package
Represents an action involving a change that applies in some way to an inventory or other item-source.
Table of Contents
- $sourceItem : Item
- $targetItem : Item
- __construct() : mixed
- execute() : void
- Performs actions needed to complete the inventory-action server-side. This will only be called if the transaction which it is part of is considered valid.
- 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
- Called when the action is added to the specified InventoryTransaction.
- onPreExecute() : bool
- Called by inventory transactions before any actions are processed. If this returns false, the transaction will be cancelled.
- validate() : void
- Returns whether this action is currently valid. This should perform any necessary sanity checks.
Properties
$sourceItem
protected
Item
$sourceItem
$targetItem
protected
Item
$targetItem
Methods
__construct()
public
__construct(Item $sourceItem, Item $targetItem) : mixed
Parameters
Return values
mixed —execute()
Performs actions needed to complete the inventory-action server-side. This will only be called if the transaction which it is part of is considered valid.
public
abstract execute(Player $source) : void
Parameters
- $source : Player
Return values
void —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()
Called when the action is added to the specified InventoryTransaction.
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()
Returns whether this action is currently valid. This should perform any necessary sanity checks.
public
abstract validate(Player $source) : void
Parameters
- $source : Player