mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Tiles and Entities won't get wiped on level unload
This commit is contained in:
parent
38c50c2fec
commit
164b420af6
1 changed files with 9 additions and 2 deletions
|
|
@ -126,11 +126,12 @@ class LevelAPI{
|
|||
return true;
|
||||
}
|
||||
|
||||
public function unloadLevel(Level $level){
|
||||
public function unloadLevel(Level $level, $force = false){
|
||||
$name = $level->getName();
|
||||
if($name === $this->default){
|
||||
if($name === $this->default and $force !== true){
|
||||
return false;
|
||||
}
|
||||
console("[INFO] Unloading level \"".$name."\"");
|
||||
$level->nextSave = PHP_INT_MAX;
|
||||
$level->save();
|
||||
foreach($this->server->api->player->getAll($level) as $player){
|
||||
|
|
@ -219,6 +220,12 @@ class LevelAPI{
|
|||
$level->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct(){
|
||||
foreach($this->levels as $level){
|
||||
$this->unloadLevel($level, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function getSpawn(){
|
||||
return $this->server->spawn;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue