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:
Dylan K. Taylor
2021-06-27 20:56:51 +01:00
parent 3dd33cd35e
commit 6fb8ac211e
5 changed files with 11 additions and 21 deletions

View File

@@ -53,9 +53,8 @@ class GamemodeCommand extends VanillaCommand{
throw new InvalidCommandSyntaxException();
}
try{
$gameMode = GameMode::fromString($args[0]);
}catch(\InvalidArgumentException $e){
$gameMode = GameMode::fromString($args[0]);
if($gameMode === null){
$sender->sendMessage("Unknown game mode");
return true;
}