mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Make GameMode::fromString() and PluginEnableOrder::fromString() return null, instead of throwing exceptions
since these are always used for handling userdata, it doesn't make sense for them to throw exceptions.
This commit is contained in:
@ -61,13 +61,9 @@ final class GameMode{
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromString(string $str) : self{
|
||||
public static function fromString(string $str) : ?self{
|
||||
self::checkInit();
|
||||
$result = self::$aliasMap[mb_strtolower($str)] ?? null;
|
||||
if($result === null){
|
||||
throw new \InvalidArgumentException("Invalid gamemode alias $str");
|
||||
}
|
||||
return $result;
|
||||
return self::$aliasMap[mb_strtolower($str)] ?? null;
|
||||
}
|
||||
|
||||
/** @var int */
|
||||
|
Reference in New Issue
Block a user