Don't prevent modification of group.<group name> nodes with permission subcommands

This commit is contained in:
Luck 2017-11-04 19:12:46 +00:00
parent d393a4c9ca
commit 76bfde4d77
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
7 changed files with 7 additions and 47 deletions

View File

@ -271,11 +271,6 @@ public class CommandManager {
return CommandResult.INVALID_ARGS;
}
if (e instanceof ArgumentUtils.UseInheritException) {
Message.USE_INHERIT_COMMAND.send(sender);
return CommandResult.INVALID_ARGS;
}
if (e instanceof ArgumentUtils.InvalidServerWorldException) {
Message.SERVER_WORLD_INVALID_ENTRY.send(sender);
return CommandResult.INVALID_ARGS;

View File

@ -168,11 +168,6 @@ public class SharedMainCommand<T extends PermissionHolder> extends SubCommand<T>
return CommandResult.INVALID_ARGS;
}
if (e instanceof ArgumentUtils.UseInheritException) {
Message.USE_INHERIT_COMMAND.send(sender);
return CommandResult.INVALID_ARGS;
}
if (e instanceof ArgumentUtils.InvalidServerWorldException) {
Message.SERVER_WORLD_INVALID_ENTRY.send(sender);
return CommandResult.INVALID_ARGS;

View File

@ -61,8 +61,8 @@ public class PermissionSet extends SharedSubCommand {
return CommandResult.NO_PERMISSION;
}
String node = ArgumentUtils.handleString(0, args);
boolean b = ArgumentUtils.handleBoolean(1, args);
String node = b ? ArgumentUtils.handleNode(0, args) : ArgumentUtils.handleString(0, args);
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {

View File

@ -66,8 +66,8 @@ public class PermissionSetTemp extends SharedSubCommand {
return CommandResult.NO_PERMISSION;
}
String node = ArgumentUtils.handleString(0, args);
boolean b = ArgumentUtils.handleBoolean(1, args);
String node = b ? ArgumentUtils.handleNode(0, args) : ArgumentUtils.handleString(0, args);
long duration = ArgumentUtils.handleDuration(2, args);
MutableContextSet context = ArgumentUtils.handleContext(3, args, plugin);

View File

@ -73,14 +73,7 @@ public class PermissionUnset extends SharedSubCommand {
return CommandResult.NO_PERMISSION;
}
DataMutateResult result;
if (node.startsWith("group.")) {
// unset exact - with false value only
result = holder.unsetPermissionExact(NodeFactory.newBuilder(node).setValue(false).withExtraContext(context).build());
} else {
// standard unset
result = holder.unsetPermission(NodeFactory.newBuilder(node).withExtraContext(context).build());
}
DataMutateResult result = holder.unsetPermission(NodeFactory.newBuilder(node).withExtraContext(context).build());
if (result.asBoolean()) {
Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), Util.contextSetToString(context));

View File

@ -37,13 +37,11 @@ import me.lucko.luckperms.common.utils.DateUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
/**
* Utility class to help process arguments, and throw checked exceptions if the arguments are invalid.
*/
public class ArgumentUtils {
public static final Function<String, String> WRAPPER = s -> s.contains(" ") ? "\"" + s + "\"" : s;
public static String handleString(int index, List<String> args) {
return args.get(index).replace("{SPACE}", " ");
@ -69,16 +67,6 @@ public class ArgumentUtils {
}
}
public static String handleNode(int index, List<String> args) throws ArgumentException {
String node = args.get(index).replace("{SPACE}", " ");
if (node.toLowerCase().startsWith("group.")) {
throw new UseInheritException();
}
return node;
}
public static String handleName(int index, List<String> args) throws ArgumentException {
String groupName = args.get(index).toLowerCase();
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
@ -245,20 +233,10 @@ public class ArgumentUtils {
return contextSet.makeImmutable();
}
public static abstract class ArgumentException extends CommandException {
}
public static class DetailedUsageException extends ArgumentException {
}
public static class UseInheritException extends ArgumentException {
}
public static class InvalidServerWorldException extends ArgumentException {
}
public static class PastDateException extends ArgumentException {
}
public static abstract class ArgumentException extends CommandException {}
public static class DetailedUsageException extends ArgumentException {}
public static class InvalidServerWorldException extends ArgumentException {}
public static class PastDateException extends ArgumentException {}
@Getter
@AllArgsConstructor

View File

@ -91,7 +91,6 @@ public enum Message {
GROUP_INVALID_ENTRY("&4{}&c is not a valid group name.", true),
TRACK_INVALID_ENTRY("&4{}&c is not a valid track name.", true),
SERVER_WORLD_INVALID_ENTRY("&cServer/world names can only contain alphanumeric characters and cannot exceed 36 characters in length.", true),
USE_INHERIT_COMMAND("&cUse the 'parent add' and 'parent remove' commands instead of specifying the node.", true),
/*