firstly I'm sorry for "duplicate" post. In this thread https://forums.pmmp.io/threads/on-respawn-add-effect.3553/#post-34369, people say the problem was getDeviceOS but when i remove it, it still broken... I'm using PocketMine build number #421
Rather than linking visitors to check another thread before answering this one, rephrase what you said in that post in better words.
of course it would be broken if you removed it like can a car run with their tires removed? no you should try something else... and we couldnt help you without code
PHP: public function onRespawn(PlayerRespawnEvent $event){ $player = $event->getPlayer(); $effect = Effect::getEffect(Effect::WEAKNESS); $effect->setAmplifier(0); $effect->setDuration(10000000); $player->addEffect($effect); }
Of course, it won't work only with PlayerRespawnEvent, I added addEffect on PlayerJoinEvent and it works...
I've heard of this issue before. PlayerRespawnEvent gets called pre-respawn, as that's how the event API works. All effects of the player respawning get cleared later in the respawn sequence, so you'll have to end up using a task.