Skip to content

InventoryAction ​

abstract class · pocketmine\inventory\transaction\action\InventoryAction · source

Represents an action involving a change that applies in some way to an inventory or other item-source.

Properties ​

$sourceItem ​

php
public \pocketmine\item\Item $sourceItem

$targetItem ​

php
public \pocketmine\item\Item $targetItem

Methods ​

__construct() ​

php
public function __construct(\pocketmine\item\Item $sourceItem, \pocketmine\item\Item $targetItem)

execute() ​

php
abstract public function execute(\pocketmine\player\Player $source) : 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() ​

php
public function getSourceItem() : \pocketmine\item\Item

Returns the item that was present before the action took place.

getTargetItem() ​

php
public function getTargetItem() : \pocketmine\item\Item

Returns the item that the action attempted to replace the source item with.

onAddToTransaction() ​

php
public function onAddToTransaction(\pocketmine\inventory\transaction\InventoryTransaction $transaction) : void

Deprecated

Deprecated.

Called when the action is added to the specified InventoryTransaction.

onPreExecute() ​

php
public function onPreExecute(\pocketmine\player\Player $source) : bool

Called by inventory transactions before any actions are processed. If this returns false, the transaction will be cancelled.

validate() ​

php
abstract public function validate(\pocketmine\player\Player $source) : void

Returns whether this action is currently valid. This should perform any necessary sanity checks.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.