diff --git a/src/ChestShop/EventListener.php b/src/ChestShop/EventListener.php index 46d00c6..fc205e8 100644 --- a/src/ChestShop/EventListener.php +++ b/src/ChestShop/EventListener.php @@ -11,7 +11,6 @@ use pocketmine\level\Position; use pocketmine\math\Vector3; use pocketmine\tile\Chest as TileChest; -use pocketmine\block\Chest as BlockChest; class EventListener implements Listener { @@ -55,7 +54,7 @@ public function onPlayerInteract(PlayerInteractEvent $event) $itemNum = 0; $pID = $shopInfo['productID']; $pMeta = $shopInfo['productMeta']; - for ($i = 0; $i < BlockChest::SLOTS; $i++) { + for ($i = 0; $i < $chest->getSize(); $i++) { $item = $chest->getInventory()->getItem($i); // use getDamage() method to get metadata of item if ($item->getID() === $pID and $item->getDamage() === $pMeta) $itemNum += $item->getCount(); @@ -72,7 +71,7 @@ public function onPlayerInteract(PlayerInteractEvent $event) $player->getInventory()->addItem(clone Item::get((int)$shopInfo['productID'], (int)$shopInfo['productMeta'], (int)$shopInfo['saleNum'])); $tmpNum = $shopInfo['saleNum']; - for ($i = 0; $i < BlockChest::SLOTS; $i++) { + for ($i = 0; $i < $chest->getSize(); $i++) { $item = $chest->getInventory()->getItem($i); // Use getDamage() method to get metadata of item if ($item->getID() === $pID and $item->getDamage() === $pMeta) {