GeneratorManager::getGeneratorName() now throws InvalidArgumentException on unregistered generator classes

the old behaviour allowed a bug in the world converter to go unnoticed.
This commit is contained in:
Dylan K. Taylor 2019-03-05 09:30:22 +00:00
parent 3789f4d643
commit 2cad7166b1

View File

@ -91,6 +91,7 @@ final class GeneratorManager{
* @param string $class Fully qualified name of class that extends \pocketmine\level\generator\Generator * @param string $class Fully qualified name of class that extends \pocketmine\level\generator\Generator
* *
* @return string * @return string
* @throws \InvalidArgumentException if the class type cannot be matched to a known alias
*/ */
public static function getGeneratorName(string $class) : string{ public static function getGeneratorName(string $class) : string{
foreach(self::$list as $name => $c){ foreach(self::$list as $name => $c){
@ -99,7 +100,7 @@ final class GeneratorManager{
} }
} }
return "unknown"; throw new \InvalidArgumentException("Generator class $class is not registered");
} }
private function __construct(){ private function __construct(){