Do not subscribe to broadcast permissions until the player spawns

This is unnecessary since the player won't see any messages sent before they spawn anyway. This was also causing an occasional client-sided crash due to TextPackets being sent to players at bad times during the login sequence.
This commit is contained in:
Dylan K. Taylor 2017-03-30 16:29:18 +01:00
parent cb059ea713
commit 45e5b6b04c

View File

@ -902,6 +902,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->sendPlayStatus(PlayStatusPacket::PLAYER_SPAWN);
if($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){
$this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this);
}
if($this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)){
$this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
}
$this->server->getPluginManager()->callEvent($ev = new PlayerJoinEvent($this,
new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.joined", [
$this->getDisplayName()
@ -1730,13 +1737,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
return;
}
if($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){
$this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this);
}
if($this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)){
$this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
}
foreach($this->server->getOnlinePlayers() as $p){
if($p !== $this and strtolower($p->getName()) === strtolower($this->getName())){
if($p->kick("logged in from another location") === false){