mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Stop the server if generators specified for new worlds are not valid
I thought I did this already in eff856d8e513a1f01eca16ab55bacf6e83399527, but it looks like my brain slipped a gear. Without this change, it's possible to crash the server by specifying an invalid generator for the default world if it doesn't yet exist.
This commit is contained in:
parent
9ff1bf6deb
commit
db6abfb227
@ -1097,6 +1097,7 @@ class Server{
|
|||||||
|
|
||||||
$generatorClass = $getGenerator($generatorName, $generatorOptions, $name);
|
$generatorClass = $getGenerator($generatorName, $generatorOptions, $name);
|
||||||
if($generatorClass === null){
|
if($generatorClass === null){
|
||||||
|
$anyWorldFailedToLoad = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$creationOptions->setGeneratorClass($generatorClass);
|
$creationOptions->setGeneratorClass($generatorClass);
|
||||||
@ -1133,7 +1134,11 @@ class Server{
|
|||||||
$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);
|
||||||
if($generatorClass !== null){
|
|
||||||
|
if($generatorClass === null){
|
||||||
|
$this->getLogger()->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_level_defaultError()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$creationOptions = WorldCreationOptions::create()
|
$creationOptions = WorldCreationOptions::create()
|
||||||
->setGeneratorClass($generatorClass)
|
->setGeneratorClass($generatorClass)
|
||||||
->setGeneratorOptions($generatorOptions);
|
->setGeneratorOptions($generatorOptions);
|
||||||
@ -1143,7 +1148,6 @@ class Server{
|
|||||||
}
|
}
|
||||||
$this->worldManager->generateWorld($default, $creationOptions);
|
$this->worldManager->generateWorld($default, $creationOptions);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$world = $this->worldManager->getWorldByName($default);
|
$world = $this->worldManager->getWorldByName($default);
|
||||||
if($world === null){
|
if($world === null){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user