Use enhanced switch in CommandHelper
This commit is contained in:
1 file changed
+7
-12
@@ -40,18 +40,13 @@ public final class CommandHelper {
|
|||||||
{
|
{
|
||||||
if (commandLevel instanceof Boolean) return (Boolean) commandLevel;
|
if (commandLevel instanceof Boolean) return (Boolean) commandLevel;
|
||||||
String commandLevelString = commandLevel.toString();
|
String commandLevelString = commandLevel.toString();
|
||||||
switch (commandLevelString)
|
return switch (commandLevelString)
|
||||||
{
|
{
|
||||||
case "true": return true;
|
case "true" -> true;
|
||||||
case "false": return false;
|
case "false" -> false;
|
||||||
case "ops": return source.hasPermission(2); // typical for other cheaty commands
|
case "ops" -> source.hasPermission(2); // typical for other cheaty commands
|
||||||
case "0":
|
case "0", "1", "2", "3", "4" -> source.hasPermission(Integer.parseInt(commandLevelString));
|
||||||
case "1":
|
default -> false;
|
||||||
case "2":
|
};
|
||||||
case "3":
|
|
||||||
case "4":
|
|
||||||
return source.hasPermission(Integer.parseInt(commandLevelString));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user