In this skywars plugin, I have encountered an issue that exists only for Windows 10 players. Whenever a player falls into the void, they are greeting with an infinite “generating world” message, which I believe is a Pocketmine bug. Is there anything I could do to this code In regards to PlayerDeathEvent and PlayerRespawnEvent to fix it? Thanks for the help. PHP: /** * @param PlayerDeathEvent $event */ public function onDeath(PlayerDeathEvent $event) { $player = $event->getPlayer(); if(!$this->inGame($player)) return; foreach ($event->getDrops() as $item) { $player->getLevel()->dropItem($player, $item); } $this->toRespawn[$player->getName()] = $player; $this->disconnectPlayer($player, "", true); $this->broadcastMessage("§a> {$this->plugin->getServer()->getLanguage()->translate($event->getDeathMessage())} §7[".count($this->players)."/{$this->data["slots"]}]"); $event->setDeathMessage(""); $event->setDrops([]); } /** * @param PlayerRespawnEvent $event */ public function onRespawn(PlayerRespawnEvent $event) { $player = $event->getPlayer(); if(isset($this->toRespawn[$player->getName()])) { $event->setRespawnPosition($this->plugin->getServer()->getDefaultLevel()->getSpawnLocation()); unset($this->toRespawn[$player->getName()]); } }
Use the EntityDamageByEntityEvent and do this: PHP: $hearts = $player->getHealth(); $damage = $event->getFinalDamage();if ($hearts - $damage <= 0) { $event->setCancelled(true); $player->setHealth(20);}