diff --git a/src/player/Player.php b/src/player/Player.php index 5c34c6680..3b74b27c7 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -759,7 +759,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ if($this->getHealth() <= 0){ $this->logger->debug("Quit while dead, forcing respawn"); - $this->respawn(); + $this->actuallyRespawn(); } } @@ -2100,10 +2100,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } public function respawn() : void{ - if($this->respawnLocked){ - return; - } - $this->respawnLocked = true; if($this->server->isHardcore()){ if($this->kick("You have been banned because you died in hardcore mode")){ //this allows plugins to prevent the ban by cancelling PlayerKickEvent $this->server->getNameBans()->addBan($this->getName(), "Died in hardcore mode"); @@ -2111,6 +2107,15 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ return; } + $this->actuallyRespawn(); + } + + protected function actuallyRespawn() : void{ + if($this->respawnLocked){ + return; + } + $this->respawnLocked = true; + $this->logger->debug("Waiting for spawn terrain generation for respawn"); $spawn = $this->getSpawn(); $spawn->getWorld()->orderChunkPopulation($spawn->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawn->getFloorZ() >> Chunk::COORD_BIT_SIZE, null)->onCompletion(