Check player online status, closes #1983

This commit is contained in:
Shoghi Cervantes 2014-08-27 11:28:49 +02:00
parent e0fc3784ad
commit f7e2d31f0a
3 changed files with 9 additions and 5 deletions

View File

@ -2137,7 +2137,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->connected = false; $this->connected = false;
$this->interface->close($this, $reason); $this->interface->close($this, $reason);
$this->server->removePlayer($this);
$this->getLevel()->freeAllChunks($this); $this->getLevel()->freeAllChunks($this);
@ -2157,6 +2156,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->loadQueue = []; $this->loadQueue = [];
unset($this->buffer); unset($this->buffer);
} }
$this->server->removePlayer($this);
} }
/** /**

View File

@ -1984,10 +1984,13 @@ class Server{
} }
public function doAutoSave(){ public function doAutoSave(){
Timings::$worldSaveTimer->startTiming(); Timings::$worldSaveTimer->startTiming();
foreach($this->getOnlinePlayers() as $player){ foreach($this->getOnlinePlayers() as $index => $player){
$player->save(); if($player->isOnline()){
$player->save();
}elseif(!$player->isConnected()){
unset($this->players[$index]);
}
} }
foreach($this->getLevels() as $level){ foreach($this->getLevels() as $level){

View File

@ -251,7 +251,7 @@ class Level implements ChunkManager, Metadatable{
$this->nextSave = microtime(true) + 90; $this->nextSave = microtime(true) + 90;
$this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 3))); $this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 3)));
$this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 128); $this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 80);
$this->chunkTickList = []; $this->chunkTickList = [];
$this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", false); $this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", false);
$this->timings = new LevelTimings($this); $this->timings = new LevelTimings($this);