mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Stop the server if any world listed by config fails to load or be generated during startup
closes #3162 this does not affect worlds loaded by plugins; they may continue to handle errors as they see fit
This commit is contained in:
parent
90a369f0b6
commit
eff856d8e5
@ -1006,6 +1006,7 @@ class Server{
|
||||
$this->enablePlugins(PluginEnableOrder::STARTUP());
|
||||
|
||||
if(!$this->startupPrepareWorlds()){
|
||||
$this->forceShutdown();
|
||||
return;
|
||||
}
|
||||
$this->enablePlugins(PluginEnableOrder::POSTWORLD());
|
||||
@ -1072,13 +1073,21 @@ class Server{
|
||||
return $generatorEntry->getGeneratorClass();
|
||||
};
|
||||
|
||||
$anyWorldFailedToLoad = false;
|
||||
|
||||
foreach((array) $this->configGroup->getProperty("worlds", []) as $name => $options){
|
||||
if($options === null){
|
||||
$options = [];
|
||||
}elseif(!is_array($options)){
|
||||
//TODO: this probably should be an error
|
||||
continue;
|
||||
}
|
||||
if(!$this->worldManager->loadWorld($name, true) && !$this->worldManager->isWorldGenerated($name)){
|
||||
if(!$this->worldManager->loadWorld($name, true)){
|
||||
if($this->worldManager->isWorldGenerated($name)){
|
||||
//allow checking if other worlds are loadable, so the user gets all the errors in one go
|
||||
$anyWorldFailedToLoad = true;
|
||||
continue;
|
||||
}
|
||||
$creationOptions = WorldCreationOptions::create();
|
||||
//TODO: error checking
|
||||
|
||||
@ -1114,7 +1123,12 @@ class Server{
|
||||
$default = "world";
|
||||
$this->configGroup->setConfigString("level-name", "world");
|
||||
}
|
||||
if(!$this->worldManager->loadWorld($default, true) && !$this->worldManager->isWorldGenerated($default)){
|
||||
if(!$this->worldManager->loadWorld($default, true)){
|
||||
if($this->worldManager->isWorldGenerated($default)){
|
||||
$this->getLogger()->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_level_defaultError()));
|
||||
|
||||
return false;
|
||||
}
|
||||
$generatorName = $this->configGroup->getConfigString("level-type");
|
||||
$generatorOptions = $this->configGroup->getConfigString("generator-settings");
|
||||
$generatorClass = $getGenerator($generatorName, $generatorOptions, $default);
|
||||
@ -1132,15 +1146,12 @@ class Server{
|
||||
|
||||
$world = $this->worldManager->getWorldByName($default);
|
||||
if($world === null){
|
||||
$this->getLogger()->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_level_defaultError()));
|
||||
$this->forceShutdown();
|
||||
|
||||
return false;
|
||||
throw new AssumptionFailedError("We just loaded/generated the default world, so it must exist");
|
||||
}
|
||||
$this->worldManager->setDefaultWorld($world);
|
||||
}
|
||||
|
||||
return true;
|
||||
return !$anyWorldFailedToLoad;
|
||||
}
|
||||
|
||||
private function startupPrepareConnectableNetworkInterfaces(string $ip, int $port, bool $ipV6, bool $useQuery) : bool{
|
||||
|
Loading…
x
Reference in New Issue
Block a user