Replace Player->joined with Player->spawned, remove redundant field

spawned serves basically the same purpose as joined does.
This commit is contained in:
Dylan K. Taylor 2017-11-17 13:44:37 +00:00
parent adabfe78df
commit 7c2dccd2a6
2 changed files with 4 additions and 8 deletions

View File

@ -197,7 +197,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
public $playedBefore; public $playedBefore;
public $spawned = false; public $spawned = false;
public $loggedIn = false; public $loggedIn = false;
public $joined = false;
public $gamemode; public $gamemode;
public $lastBreak; public $lastBreak;
/** @var bool */ /** @var bool */
@ -303,7 +302,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
* @return TranslationContainer|string * @return TranslationContainer|string
*/ */
public function getLeaveMessage(){ public function getLeaveMessage(){
if($this->joined){ if($this->spawned){
return new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.left", [ return new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.left", [
$this->getDisplayName() $this->getDisplayName()
]); ]);
@ -988,8 +987,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($this->getHealth() <= 0){ if($this->getHealth() <= 0){
$this->sendRespawnPacket($this->getSpawn()); $this->sendRespawnPacket($this->getSpawn());
} }
$this->joined = true;
} }
protected function sendRespawnPacket(Vector3 $pos){ protected function sendRespawnPacket(Vector3 $pos){
@ -3319,7 +3316,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->stopSleep(); $this->stopSleep();
if($this->joined){ if($this->spawned){
$this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message, $reason)); $this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message, $reason));
if($ev->getQuitMessage() != ""){ if($ev->getQuitMessage() != ""){
$this->server->broadcastMessage($ev->getQuitMessage()); $this->server->broadcastMessage($ev->getQuitMessage());
@ -3332,7 +3329,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->server->getLogger()->logException($e); $this->server->getLogger()->logException($e);
} }
} }
$this->joined = false;
if($this->isValid()){ if($this->isValid()){
foreach($this->usedChunks as $index => $d){ foreach($this->usedChunks as $index => $d){

View File

@ -2357,7 +2357,7 @@ class Server{
foreach($this->players as $p){ foreach($this->players as $p){
if(!$p->loggedIn and ($tickTime - $p->creationTime) >= 10){ if(!$p->loggedIn and ($tickTime - $p->creationTime) >= 10){
$p->close("", "Login timeout"); $p->close("", "Login timeout");
}elseif($this->alwaysTickPlayers and $p->joined){ }elseif($this->alwaysTickPlayers and $p->spawned){
$p->onUpdate($currentTick); $p->onUpdate($currentTick);
} }
} }
@ -2402,7 +2402,7 @@ class Server{
if($this->getAutoSave()){ if($this->getAutoSave()){
Timings::$worldSaveTimer->startTiming(); Timings::$worldSaveTimer->startTiming();
foreach($this->players as $index => $player){ foreach($this->players as $index => $player){
if($player->joined){ if($player->spawned){
$player->save(true); $player->save(true);
}elseif(!$player->isConnected()){ }elseif(!$player->isConnected()){
$this->removePlayer($player); $this->removePlayer($player);