protected function doFirstSpawn()
{
$this->spawned = true;
$this->sendPotionEffects($this);
$this->sendData($this);
$pk = new SetTimePacket();
$pk->time = $this->level->getTime();
$pk->started = $this->level->stopTime == false;
$this->dataPacket($pk);
$pos = $this->level->getSafeSpawn($this);
$this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $pos));
$pos = $ev->getRespawnPosition();
if ($pos->getY() < 127) {
$pos = $pos->add(0, 0.2, 0);
}
/*$pk = new RespawnPacket();
$pk->x = $pos->x;
$pk->y = $pos->y;
$pk->z = $pos->z;
$this->dataPacket($pk);*/
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::PLAYER_SPAWN;
$this->dataPacket($pk);
$this->noDamageTicks = 60;
foreach ($this->usedChunks as $index => $c) {
Level::getXZ($index, $chunkX, $chunkZ);
foreach ($this->level->getChunkEntities($chunkX, $chunkZ) as $entity) {
if ($entity !== $this and !$entity->closed and $entity->isAlive()) {
$entity->spawnTo($this);
}
}
}
$this->teleport($pos);
$this->allowFlight = ($this->gamemode == 3 or $this->gamemode == 1);
$this->setHealth($this->getHealth());
$this->server->getPluginManager()->callEvent($ev = new PlayerJoinEvent($this, new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.joined", [$this->getDisplayName()])));
$this->sendSettings();
if (strlen(trim($msg = $ev->getJoinMessage())) > 0) {
if ($this->server->playerMsgType === Server::PLAYER_MSG_TYPE_MESSAGE) {
$this->server->broadcastMessage($msg);
} elseif ($this->server->playerMsgType === Server::PLAYER_MSG_TYPE_TIP) {
$this->server->broadcastTip(str_replace("@player", $this->getName(), $this->server->playerLoginMsg));
} elseif ($this->server->playerMsgType === Server::PLAYER_MSG_TYPE_POPUP) {
$this->server->broadcastPopup(str_replace("@player", $this->getName(), $this->server->playerLoginMsg));
}
}
$this->server->onPlayerLogin($this);
$this->spawnToAll();
$this->level->getWeather()->sendWeather($this);
if ($this->server->dserverConfig["enable"] and $this->server->dserverConfig["queryAutoUpdate"]) {
$this->server->updateQuery();
}
/*if($this->server->getUpdater()->hasUpdate() and $this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)){
$this->server->getUpdater()->showPlayerUpdate($this);
}*/
if ($this->getHealth() <= 0) {
$pk = new RespawnPacket();
$pos = $this->getSpawn();
$pk->x = $pos->x;
$pk->y = $pos->y;
$pk->z = $pos->z;
$this->dataPacket($pk);
}
$this->inventory->sendContents($this);
$this->inventory->sendArmorContents($this);
}