mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
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:
@ -79,20 +79,11 @@ final class GeneratorManager{
|
||||
*
|
||||
* @param bool $throwOnMissing @deprecated this is for backwards compatibility only
|
||||
*
|
||||
* @return string Name of class that extends Generator
|
||||
* @phpstan-return class-string<Generator>
|
||||
*
|
||||
* @throws \InvalidArgumentException if the generator type isn't registered
|
||||
* @return string|null Name of class that extends Generator, or null if no generator is mapped to that name
|
||||
* @phpstan-return class-string<Generator>|null
|
||||
*/
|
||||
public function getGenerator(string $name, bool $throwOnMissing = false){
|
||||
if(isset($this->list[$name = strtolower($name)])){
|
||||
return $this->list[$name];
|
||||
}
|
||||
|
||||
if($throwOnMissing){
|
||||
throw new \InvalidArgumentException("Alias \"$name\" does not map to any known generator");
|
||||
}
|
||||
return Normal::class;
|
||||
public function getGenerator(string $name, bool $throwOnMissing = false) : ?string{
|
||||
return $this->list[strtolower($name)] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user