mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Chunk unloading fixed
This commit is contained in:
parent
f1e4bb0f62
commit
fb69cf3392
@ -219,7 +219,7 @@ class PMFLevel extends PMF{
|
|||||||
public function unloadChunk($X, $Z, $save = true){
|
public function unloadChunk($X, $Z, $save = true){
|
||||||
$X = (int) $X;
|
$X = (int) $X;
|
||||||
$Z = (int) $Z;
|
$Z = (int) $Z;
|
||||||
if($this->isChunkLoaded($X, $Z)){
|
if(!$this->isChunkLoaded($X, $Z)){
|
||||||
return false;
|
return false;
|
||||||
}elseif($save !== false){
|
}elseif($save !== false){
|
||||||
$this->saveChunk($X, $Z);
|
$this->saveChunk($X, $Z);
|
||||||
|
@ -27,7 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
class Level{
|
class Level{
|
||||||
public $entities, $tileEntities;
|
public $entities, $tileEntities;
|
||||||
private $level, $time, $startCheck, $startTime, $server, $name, $usedChunks;
|
private $level, $time, $startCheck, $startTime, $server, $name, $usedChunks, $nextSave;
|
||||||
|
|
||||||
public function __construct(PMFLevel $level, Config $entities, Config $tileEntities, $name){
|
public function __construct(PMFLevel $level, Config $entities, Config $tileEntities, $name){
|
||||||
$this->server = ServerAPI::request();
|
$this->server = ServerAPI::request();
|
||||||
@ -35,7 +35,7 @@ class Level{
|
|||||||
$this->entities = $entities;
|
$this->entities = $entities;
|
||||||
$this->tileEntities = $tileEntities;
|
$this->tileEntities = $tileEntities;
|
||||||
$this->startTime = $this->time = (int) $this->level->getData("time");
|
$this->startTime = $this->time = (int) $this->level->getData("time");
|
||||||
$this->lastSave = $this->startCheck = microtime(true);
|
$this->nextSave = $this->startCheck = microtime(true);
|
||||||
$this->nextSave += 30;
|
$this->nextSave += 30;
|
||||||
$this->server->schedule(15, array($this, "checkThings"), array(), true);
|
$this->server->schedule(15, array($this, "checkThings"), array(), true);
|
||||||
$this->server->event("server.close", array($this, "save"));
|
$this->server->event("server.close", array($this, "save"));
|
||||||
@ -72,11 +72,11 @@ class Level{
|
|||||||
unset($this->usedChunks[$i]);
|
unset($this->usedChunks[$i]);
|
||||||
$X = explode(".", $i);
|
$X = explode(".", $i);
|
||||||
$Z = array_pop($X);
|
$Z = array_pop($X);
|
||||||
$this->level->unloadChunk((int) $X, (int) $Z);
|
$this->level->unloadChunk((int) array_pop($X), (int) $Z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->lastSave < $now){
|
if($this->nextSave < $now){
|
||||||
$this->save();
|
$this->save();
|
||||||
$this->lastSave = $now + 30;
|
$this->lastSave = $now + 30;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user