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

@ -25,6 +25,7 @@ namespace pocketmine\world\format\io;
use pocketmine\utils\Filesystem;
use pocketmine\world\generator\GeneratorManager;
use pocketmine\world\generator\normal\Normal;
use pocketmine\world\WorldCreationOptions;
use Webmozart\PathUtil\Path;
use function basename;
@ -112,7 +113,9 @@ class FormatConverter{
Filesystem::recursiveUnlink($convertedOutput);
}
$this->newProvider->generate($convertedOutput, $data->getName(), WorldCreationOptions::create()
->setGeneratorClass(GeneratorManager::getInstance()->getGenerator($data->getGenerator()))
//TODO: defaulting to NORMAL here really isn't very good behaviour, but it's consistent with what we already
//did previously; besides, WorldManager checks for unknown generators before this is reached anyway.
->setGeneratorClass(GeneratorManager::getInstance()->getGenerator($data->getGenerator()) ?? Normal::class)
->setGeneratorOptions($data->getGeneratorOptions())
->setSeed($data->getSeed())
->setSpawnPosition($data->getSpawn())