sourceItem; } /** * Returns the item that the action attempted to replace the source item with. */ public function getTargetItem() : Item{ return clone $this->targetItem; } /** * Returns whether this action is currently valid. This should perform any necessary sanity checks. * * @throws TransactionValidationException */ abstract public function validate(Player $source) : void; /** * Called when the action is added to the specified InventoryTransaction. */ public function onAddToTransaction(InventoryTransaction $transaction) : void{ } /** * Called by inventory transactions before any actions are processed. If this returns false, the transaction will * be cancelled. */ public function onPreExecute(Player $source) : bool{ return true; } /** * 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. */ abstract public function execute(Player $source) : void; }