I am working on a plugin that clears a player's effects and resets their health upon entering a specific world, the server's lobby. Here's my attempt to far, but to no avail. Maybe I need to place it under a different function than onJoin()? I just want to make it so that whenever a player enters a world, their health and effects are reset. Any help would be greatly appreciated. PHP: public function onJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $this->onItem($player); if($player->getLevel()->getName() === "Lobby"){ $player->removeAllEffects(); $player = $event->getPlayer(); $player->getArmorInventory()->clearAll(); $player->setHealth(20); $player->setFood(20); $player->setGamemode(0); $player->removeAllEffects(true); } }
use EntityLevelChangeEvent, ensure $event->getEntity() is player and check that $event->getTarget() is the world you want