mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-05 09:39:56 +00:00
Fixed plugins causing crashes by using Level->unload() and add a warning
yes, we don't want you to use this, but it still shouldn't crash if it can be prevented...
This commit is contained in:
parent
3c02a6a8ed
commit
28bce8d48c
@ -983,13 +983,16 @@ class Server{
|
||||
if($level === $this->getDefaultLevel() and !$forceUnload){
|
||||
throw new \InvalidStateException("The default level cannot be unloaded while running, please switch levels.");
|
||||
}
|
||||
if($level->unload($forceUnload) === true){
|
||||
unset($this->levels[$level->getId()]);
|
||||
|
||||
return true;
|
||||
}
|
||||
return $level->unload($forceUnload);
|
||||
}
|
||||
|
||||
return false;
|
||||
/**
|
||||
* @internal
|
||||
* @param Level $level
|
||||
*/
|
||||
public function removeLevel(Level $level) : void{
|
||||
unset($this->levels[$level->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -473,6 +473,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal DO NOT use this from plugins, it's for internal use only. Use Server->unloadLevel() instead.
|
||||
*
|
||||
* Unloads the current level from memory safely
|
||||
*
|
||||
* @param bool $force default false, force unload of default level
|
||||
@ -507,6 +509,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->server->setDefaultLevel(null);
|
||||
}
|
||||
|
||||
$this->server->removeLevel($this);
|
||||
|
||||
$this->close();
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user