mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +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());
|
$this->enablePlugins(PluginEnableOrder::STARTUP());
|
||||||
|
|
||||||
if(!$this->startupPrepareWorlds()){
|
if(!$this->startupPrepareWorlds()){
|
||||||
|
$this->forceShutdown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->enablePlugins(PluginEnableOrder::POSTWORLD());
|
$this->enablePlugins(PluginEnableOrder::POSTWORLD());
|
||||||
@ -1072,13 +1073,21 @@ class Server{
|
|||||||
return $generatorEntry->getGeneratorClass();
|
return $generatorEntry->getGeneratorClass();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$anyWorldFailedToLoad = false;
|
||||||
|
|
||||||
foreach((array) $this->configGroup->getProperty("worlds", []) as $name => $options){
|
foreach((array) $this->configGroup->getProperty("worlds", []) as $name => $options){
|
||||||
if($options === null){
|
if($options === null){
|
||||||
$options = [];
|
$options = [];
|
||||||
}elseif(!is_array($options)){
|
}elseif(!is_array($options)){
|
||||||
|
//TODO: this probably should be an error
|
||||||
continue;
|
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();
|
$creationOptions = WorldCreationOptions::create();
|
||||||
//TODO: error checking
|
//TODO: error checking
|
||||||
|
|
||||||
@ -1114,7 +1123,12 @@ class Server{
|
|||||||
$default = "world";
|
$default = "world";
|
||||||
$this->configGroup->setConfigString("level-name", "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");
|
$generatorName = $this->configGroup->getConfigString("level-type");
|
||||||
$generatorOptions = $this->configGroup->getConfigString("generator-settings");
|
$generatorOptions = $this->configGroup->getConfigString("generator-settings");
|
||||||
$generatorClass = $getGenerator($generatorName, $generatorOptions, $default);
|
$generatorClass = $getGenerator($generatorName, $generatorOptions, $default);
|
||||||
@ -1132,15 +1146,12 @@ class Server{
|
|||||||
|
|
||||||
$world = $this->worldManager->getWorldByName($default);
|
$world = $this->worldManager->getWorldByName($default);
|
||||||
if($world === null){
|
if($world === null){
|
||||||
$this->getLogger()->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_level_defaultError()));
|
throw new AssumptionFailedError("We just loaded/generated the default world, so it must exist");
|
||||||
$this->forceShutdown();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
$this->worldManager->setDefaultWorld($world);
|
$this->worldManager->setDefaultWorld($world);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return !$anyWorldFailedToLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function startupPrepareConnectableNetworkInterfaces(string $ip, int $port, bool $ipV6, bool $useQuery) : bool{
|
private function startupPrepareConnectableNetworkInterfaces(string $ip, int $port, bool $ipV6, bool $useQuery) : bool{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user