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

View File

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