mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Fixed worlds with unknown generators silently getting wrong generator, closes #2860
This commit is contained in:
@ -383,7 +383,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->worldHeight = $this->provider->getWorldHeight();
|
||||
|
||||
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.level.preparing", [$this->displayName]));
|
||||
$this->generator = GeneratorManager::getGenerator($this->provider->getGenerator());
|
||||
$this->generator = GeneratorManager::getGenerator($this->provider->getGenerator(), true);
|
||||
//TODO: validate generator options
|
||||
|
||||
$this->folderName = $name;
|
||||
|
@ -74,14 +74,19 @@ final class GeneratorManager{
|
||||
* Returns a class name of a registered Generator matching the given name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $throwOnMissing @deprecated this is for backwards compatibility only
|
||||
*
|
||||
* @return string|Generator Name of class that extends Generator (not an actual Generator object)
|
||||
* @throws \InvalidArgumentException if the generator type isn't registered
|
||||
*/
|
||||
public static function getGenerator(string $name){
|
||||
public static function getGenerator(string $name, bool $throwOnMissing = false){
|
||||
if(isset(self::$list[$name = strtolower($name)])){
|
||||
return self::$list[$name];
|
||||
}
|
||||
|
||||
if($throwOnMissing){
|
||||
throw new \InvalidArgumentException("Alias \"$name\" does not map to any known generator");
|
||||
}
|
||||
return Normal::class;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user