Ok so i have some issues with teleporting a player to spawn. 1. When i use Player::setLevel() then Player::teleport() the server crashes due to getEntites() on null because of chunk hashing blah blah 2. If i use just Player::teleport() the crashing does not happen but the player cant move and is stuck This all happens when i call the win() function(my own code) Here is my current code: PHP: /** * @param Player $player */ public function win(Player $player){ $level = $this->getServer()->getDefaultLevel()->getSafeSpawn(); $player->teleport(new Position($level->x, $level->y+2, $level->z)); $this->stats->updateGapple($player); $player->getInventory()->setContents([]); if($this->isInMatch($player) === true){ $match = $this->getMatch($player); $player->sendMessage(self::PREFIX."You won on ".$match->getName()."!"); $match->end(); } }
It's good practice to post the answer, even if it's your own question, in case other people have a similar problem.
I just changed how i teleport them Code: PHP: /** * @param Player $player */ public function win(Player $player){ $level = $this->getServer()->getDefaultLevel()->getSpawnLocation(); $player->teleport($level); $this->stats->updateGapple($player); $player->getInventory()->setContents([]); if($this->isInMatch($player) === true){ $match = $this->getMatch($player); $player->sendMessage(self::PREFIX."You won on ".$match->getName()."!"); $match->end(); } }