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,12 +299,19 @@ 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(){
if($this->joined){
return new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.left", [ return new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.left", [
$this->getDisplayName() $this->getDisplayName()
]); ]);
} }
return "";
}
/** /**
* This might disappear in the future. * This might disappear in the future.
* Please use getUniqueId() instead (IP + clientId + name combo, in the future it'll change to real UUID for online * Please use getUniqueId() instead (IP + clientId + name combo, in the future it'll change to real UUID for online
@ -3444,12 +3451,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->usedChunks = []; $this->usedChunks = [];
$this->loadQueue = []; $this->loadQueue = [];
if($this->loggedIn){
foreach($this->server->getOnlinePlayers() as $player){ foreach($this->server->getOnlinePlayers() as $player){
if(!$player->canSee($this)){ if(!$player->canSee($this)){
$player->showPlayer($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);
} }
} }