Deprecate InventoryAction->onAddToTransaction()

this never made any sense
This commit is contained in:
Dylan K. Taylor 2024-11-25 21:39:35 +00:00
parent 52fe2cb97f
commit 905a10e980
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 4 additions and 18 deletions

View File

@ -111,6 +111,9 @@ class InventoryTransaction{
if(!isset($this->actions[$hash = spl_object_id($action)])){
$this->actions[$hash] = $action;
$action->onAddToTransaction($this);
if($action instanceof SlotChangeAction && !isset($this->inventories[$inventoryId = spl_object_id($action->getInventory())])){
$this->inventories[$inventoryId] = $action->getInventory();
}
}else{
throw new \InvalidArgumentException("Tried to add the same action to a transaction twice");
}
@ -129,16 +132,6 @@ class InventoryTransaction{
$this->actions = $actions;
}
/**
* @internal This method should not be used by plugins, it's used to add tracked inventories for InventoryActions
* involving inventories.
*/
public function addInventory(Inventory $inventory) : void{
if(!isset($this->inventories[$hash = spl_object_id($inventory)])){
$this->inventories[$hash] = $inventory;
}
}
/**
* @param Item[] $needItems
* @param Item[] $haveItems

View File

@ -60,6 +60,7 @@ abstract class InventoryAction{
/**
* Called when the action is added to the specified InventoryTransaction.
* @deprecated
*/
public function onAddToTransaction(InventoryTransaction $transaction) : void{

View File

@ -25,7 +25,6 @@ namespace pocketmine\inventory\transaction\action;
use pocketmine\inventory\Inventory;
use pocketmine\inventory\SlotValidatedInventory;
use pocketmine\inventory\transaction\InventoryTransaction;
use pocketmine\inventory\transaction\TransactionValidationException;
use pocketmine\item\Item;
use pocketmine\player\Player;
@ -85,13 +84,6 @@ class SlotChangeAction extends InventoryAction{
}
}
/**
* Adds this action's target inventory to the transaction's inventory list.
*/
public function onAddToTransaction(InventoryTransaction $transaction) : void{
$transaction->addInventory($this->inventory);
}
/**
* Sets the item into the target inventory.
*/