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:
Dylan K. Taylor
2017-09-25 09:46:09 +01:00
parent 3c02a6a8ed
commit 28bce8d48c
2 changed files with 12 additions and 5 deletions

View File

@ -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()]);
}
/**