mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 19:46:32 +01:00
Default the value to true in set/settemp commands if no arg is given. Closes #82
This commit is contained in:
parent
70aa3964ee
commit
22ccce3208
@ -46,10 +46,10 @@ import static me.lucko.luckperms.common.commands.SubCommand.getPermissionTabComp
|
|||||||
public class PermissionSet extends SharedSubCommand {
|
public class PermissionSet extends SharedSubCommand {
|
||||||
public PermissionSet() {
|
public PermissionSet() {
|
||||||
super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET,
|
super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET,
|
||||||
Predicates.notInRange(2, 4),
|
Predicates.notInRange(1, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("node", true, "the permission node to set"),
|
Arg.create("node", true, "the permission node to set"),
|
||||||
Arg.create("true|false", true, "the value of the node"),
|
Arg.create("true|false", false, "the value of the node"),
|
||||||
Arg.create("server", false, "the server to add the permission node on"),
|
Arg.create("server", false, "the server to add the permission node on"),
|
||||||
Arg.create("world", false, "the world to add the permission node on")
|
Arg.create("world", false, "the world to add the permission node on")
|
||||||
)
|
)
|
||||||
|
@ -47,10 +47,10 @@ import static me.lucko.luckperms.common.commands.SubCommand.getPermissionTabComp
|
|||||||
public class PermissionSetTemp extends SharedSubCommand {
|
public class PermissionSetTemp extends SharedSubCommand {
|
||||||
public PermissionSetTemp() {
|
public PermissionSetTemp() {
|
||||||
super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP,
|
super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP,
|
||||||
Permission.GROUP_PERM_SETTEMP, Predicates.notInRange(3, 5),
|
Permission.GROUP_PERM_SETTEMP, Predicates.notInRange(2, 5),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("node", true, "the permission node to set"),
|
Arg.create("node", true, "the permission node to set"),
|
||||||
Arg.create("true|false", true, "the value of the node"),
|
Arg.create("true|false", false, "the value of the node"),
|
||||||
Arg.create("duration", true, "the duration until the permission node expires"),
|
Arg.create("duration", true, "the duration until the permission node expires"),
|
||||||
Arg.create("server", false, "the server to add the permission node on"),
|
Arg.create("server", false, "the server to add the permission node on"),
|
||||||
Arg.create("world", false, "the world to add the permission node on")
|
Arg.create("world", false, "the world to add the permission node on")
|
||||||
|
@ -66,12 +66,16 @@ public class ArgumentUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleBoolean(int index, List<String> args) throws ArgumentException {
|
public static boolean handleBoolean(int index, List<String> args) throws ArgumentException {
|
||||||
|
if (index < args.size()) {
|
||||||
String bool = args.get(index);
|
String bool = args.get(index);
|
||||||
if (!bool.equalsIgnoreCase("true") && !bool.equalsIgnoreCase("false")) {
|
if (bool.equalsIgnoreCase("true") || bool.equalsIgnoreCase("false")) {
|
||||||
throw new DetailedUsageException();
|
|
||||||
}
|
|
||||||
return Boolean.parseBoolean(bool);
|
return Boolean.parseBoolean(bool);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args.add(index, "true");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static String handleServer(int index, List<String> args) throws ArgumentException {
|
public static String handleServer(int index, List<String> args) throws ArgumentException {
|
||||||
if (args.size() > index) {
|
if (args.size() > index) {
|
||||||
|
Loading…
Reference in New Issue
Block a user