Workaround for some plugins crashing clients during PlayerLoginEvent

This commit is contained in:
Dylan K. Taylor 2017-06-02 17:06:01 +01:00
parent e4e4ef5f2a
commit 087a994393

View File

@ -1840,12 +1840,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
protected function completeLoginSequence(){
parent::__construct($this->level, $this->namedtag);
$this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
if($ev->isCancelled()){
$this->close($this->getLeaveMessage(), $ev->getKickMessage());
return;
}
if(!$this->hasValidSpawnPosition() and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level){
$this->spawnPosition = new WeakPosition($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
@ -1879,6 +1873,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$pk->worldName = $this->server->getMotd();
$this->dataPacket($pk);
$this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
if($ev->isCancelled()){
$this->close($this->getLeaveMessage(), $ev->getKickMessage());
return;
}
$this->level->sendTime($this);
$this->sendAttributes(true);