More hack-fixes for #1220

Player and network really need to get divorced, and fast.
This commit is contained in:
Dylan K. Taylor 2017-07-27 11:25:40 +01:00
parent e8be8550a0
commit 8274f5b3cc

View File

@ -299,10 +299,17 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
/** @var int|null */ /** @var int|null */
protected $lineHeight = null; protected $lineHeight = null;
/**
* @return TranslationContainer|string
*/
public function getLeaveMessage(){ public function getLeaveMessage(){
return new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.left", [ if($this->joined){
$this->getDisplayName() return new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.left", [
]); $this->getDisplayName()
]);
}
return "";
} }
/** /**
@ -3444,12 +3451,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->usedChunks = []; $this->usedChunks = [];
$this->loadQueue = []; $this->loadQueue = [];
foreach($this->server->getOnlinePlayers() as $player){ if($this->loggedIn){
if(!$player->canSee($this)){ foreach($this->server->getOnlinePlayers() as $player){
$player->showPlayer($this); if(!$player->canSee($this)){
$player->showPlayer($this);
}
} }
$this->hiddenPlayers = [];
} }
$this->hiddenPlayers = [];
foreach($this->windowIndex as $window){ foreach($this->windowIndex as $window){
$this->removeWindow($window); $this->removeWindow($window);
@ -3460,8 +3469,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
parent::close(); parent::close();
$this->spawned = false; $this->spawned = false;
$this->interface->close($this, $notify ? $reason : "");
if($this->loggedIn){ if($this->loggedIn){
$this->loggedIn = false; $this->loggedIn = false;
$this->server->removeOnlinePlayer($this); $this->server->removeOnlinePlayer($this);
@ -3489,6 +3496,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}catch(\Throwable $e){ }catch(\Throwable $e){
$this->server->getLogger()->logException($e); $this->server->getLogger()->logException($e);
}finally{ }finally{
$this->interface->close($this, $notify ? $reason : "");
$this->server->removePlayer($this); $this->server->removePlayer($this);
} }
} }