Added exception when unloading the default level without switching it first, #3112

This commit is contained in:
Shoghi Cervantes 2015-06-05 15:59:47 +02:00
parent 1e03c5b795
commit bdb9b1865b

View File

@ -1015,6 +1015,9 @@ class Server{
* @return bool * @return bool
*/ */
public function unloadLevel(Level $level, $forceUnload = false){ public function unloadLevel(Level $level, $forceUnload = false){
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){ if($level->unload($forceUnload) === true){
unset($this->levels[$level->getId()]); unset($this->levels[$level->getId()]);