PHP: public function getPotionCount(Player $sender){ $name = $sender->getName(); $number = 0; $inventory = $sender->getInventory(); foreach($inventory->getContents() as $item){ if ($item instanceof \pocketmine\item\Potion or $item instanceof \pocketmine\item\SplashPotion) { $number = $number + $item->getCount(); } } return $number; }//returns the number of potions left$this->getPotionCount($sender)