Skip to content

Commit

Permalink
change SlotSafeInventory into SlotValidatedInventory
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockedPlot7560 committed Aug 22, 2024
1 parent 2a8eb2d commit 5998bca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/inventory/BaseInventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SlotValidator>
*/
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.
Expand Down
4 changes: 2 additions & 2 deletions src/inventory/transaction/action/SlotChangeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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){
Expand Down

0 comments on commit 5998bca

Please sign in to comment.