From 5998bca9f2dbacffecf62d1b04f5921535547e11 Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 Date: Thu, 22 Aug 2024 23:02:45 +0200 Subject: [PATCH] change SlotSafeInventory into SlotValidatedInventory --- src/inventory/BaseInventory.php | 4 ++-- .../{SlotSafeInventory.php => SlotValidatedInventory.php} | 6 +++--- src/inventory/transaction/action/SlotChangeAction.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/inventory/{SlotSafeInventory.php => SlotValidatedInventory.php} (87%) diff --git a/src/inventory/BaseInventory.php b/src/inventory/BaseInventory.php index 5b3299bb1d7..522c827a4b2 100644 --- a/src/inventory/BaseInventory.php +++ b/src/inventory/BaseInventory.php @@ -37,9 +37,9 @@ /** * This class provides everything needed to implement an inventory, minus the underlying storage system. * - * @phpstan-import-type SlotValidators from SlotSafeInventory + * @phpstan-import-type SlotValidators from SlotValidatedInventory */ -abstract class BaseInventory implements Inventory, SlotSafeInventory{ +abstract class BaseInventory implements Inventory, SlotValidatedInventory{ protected int $maxStackSize = Inventory::MAX_STACK; /** @var Player[] */ protected array $viewers = []; diff --git a/src/inventory/SlotSafeInventory.php b/src/inventory/SlotValidatedInventory.php similarity index 87% rename from src/inventory/SlotSafeInventory.php rename to src/inventory/SlotValidatedInventory.php index b3c4b5a88d8..f30ebf8a011 100644 --- a/src/inventory/SlotSafeInventory.php +++ b/src/inventory/SlotValidatedInventory.php @@ -27,12 +27,12 @@ use pocketmine\utils\ObjectSet; /** - * A "slot safe inventory" has validators which may restrict items - * from being placed in particular slots of the inventory. + * A "slot validated inventory" has validators which may restrict items + * from being placed in particular slots of the inventory when transactions are executed. * * @phpstan-type SlotValidators ObjectSet */ -interface SlotSafeInventory{ +interface SlotValidatedInventory{ /** * Returns a set of validators that will be used to determine whether an item can be placed in a particular slot. * All validators need to return null for the transaction to be allowed. diff --git a/src/inventory/transaction/action/SlotChangeAction.php b/src/inventory/transaction/action/SlotChangeAction.php index 46dc175d132..68c3dba1b32 100644 --- a/src/inventory/transaction/action/SlotChangeAction.php +++ b/src/inventory/transaction/action/SlotChangeAction.php @@ -24,7 +24,7 @@ namespace pocketmine\inventory\transaction\action; use pocketmine\inventory\Inventory; -use pocketmine\inventory\SlotSafeInventory; +use pocketmine\inventory\SlotValidatedInventory; use pocketmine\inventory\transaction\InventoryTransaction; use pocketmine\inventory\transaction\TransactionValidationException; use pocketmine\item\Item; @@ -75,7 +75,7 @@ public function validate(Player $source) : void{ if($this->targetItem->getCount() > $this->inventory->getMaxStackSize()){ throw new TransactionValidationException("Target item exceeds inventory max stack size"); } - if($this->inventory instanceof SlotSafeInventory && !$this->targetItem->isNull()){ + if($this->inventory instanceof SlotValidatedInventory && !$this->targetItem->isNull()){ foreach($this->inventory->getSlotValidators() as $validator){ $ret = $validator->validate($this->inventory, $this->targetItem, $this->inventorySlot); if($ret !== null){