While attempts should be made, I'll try to help anyways (not with full code though). So you want to clear the inventory of all player if they are in hub2 Now this needs to be defined more cleanly. You always need to know exactly what you want. I am assuming you want to clear the inventory of every player when they enter the "hub2" level. So, now you should start looking for something that can help your plugin to see when there is a player entering. I guess you already heard of events, so let's search for one that helps us here. https://github.com/pmmp/PocketMine-MP/tree/master/src/pocketmine/event events are located here. Now as our wanted event has something to do with a player, why not look into the "player" folder. https://github.com/pmmp/PocketMine-MP/tree/master/src/pocketmine/event/player hmmm, nothing says level or world here. you could just randomly look into other folders or perform a repo search for something like "level event". But as you might also know Players are entities, so let's look into there. https://github.com/pmmp/PocketMine-MP/tree/master/src/pocketmine/event/entity nice, there's a file called "EntityLevelChangeEvent.php", that sounds as it might help. https://github.com/pmmp/PocketMine-...tmine/event/entity/EntityLevelChangeEvent.php cool, it tells us the target level, so that's probably the level the player wants to change to https://github.com/pmmp/PocketMine-...e/event/entity/EntityLevelChangeEvent.php#L46. Just calling Event->getTarget->getName() should tell us where the Entity/Player is headed. But what is that? There's no getPlayer/getEntity function here, but we need the player instance to perform a inventory clear... Also we need to check if it is actually a player who's changing levels... That's where we need to look if the class extends any other class https://github.com/pmmp/PocketMine-...e/event/entity/EntityLevelChangeEvent.php#L30 and it sure does! let's jump into EntityEvent then. https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/event/entity/EntityEvent.php#L36 so here it is, our getEntity function. Now with that we can check if it is a player, and then perform our inv clear!
PHP: if($player->getLevel()->getName() === "hub2"){$player->getInventory()->clearAll(); //use pocketmine\inventory\InventoryBase;} =)
Then say that instead of just reposting the mistake Spoiler To clear this up for anyone else reading that may be confused: You don't need to 'use' the BaseInventory class for the code above to work properly. Spoiler It's BaseInventory, not InventoryBase @KYUMA