I'm trying to make a plugin that checks if a player has a specific Item ID in their inventory. If they do, I want remove all of that item from their inventory. Is there a way I can get the amount of a specific ID that a player has in their inventory?(Example: I check and a player has at least 1 Cobblestone in their inventory. How can I remove all of the Cobblestone in their inventory?) I have searched the API and haven't found anything yet. Any help is appreciated.
Assuming `$player` is a Player object: Code: $item = Item::get(Item::COBBLESTONE, 0, 1); //item ID, damage value, count if($player->getInventory()->contains($item)){ $player->getInventory()->remove($item); //will remove ALL such items from the inventory, notice that remove() and removeItem() are not the same! } References: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/inventory/BaseInventory.php#L159 https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/inventory/BaseInventory.php#L188