GeneratorManager::getGenerator() now returns null for unknown generator aliases

instead of returning Normal::class (indistinguishable from successful match) or throwing an exception (pain in the ass to handle).
This commit is contained in:
Dylan K. Taylor
2021-10-11 16:04:36 +01:00
parent e62794e4cf
commit 7b6632941d
5 changed files with 15 additions and 20 deletions

View File

@@ -220,9 +220,8 @@ class WorldManager{
)));
return false;
}
try{
GeneratorManager::getInstance()->getGenerator($provider->getWorldData()->getGenerator(), true);
}catch(\InvalidArgumentException $e){
if(GeneratorManager::getInstance()->getGenerator($provider->getWorldData()->getGenerator()) === null){
$this->server->getLogger()->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_level_loadError(
$name,
KnownTranslationFactory::pocketmine_level_unknownGenerator($provider->getWorldData()->getGenerator())