mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-06 19:09:31 +01:00
Ease handling of group names containing spaces, after a faulty migration process
This commit is contained in:
parent
060fa6e5f7
commit
1bdb512826
@ -57,7 +57,7 @@ public class ParentRemove extends SharedSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
String groupName = ArgumentUtils.handleName(0, args);
|
String groupName = ArgumentUtils.handleNameWithSpace(0, args);
|
||||||
String server = ArgumentUtils.handleServer(1, args);
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
String world = ArgumentUtils.handleWorld(2, args);
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class ParentRemoveTemp extends SharedSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
String groupName = ArgumentUtils.handleName(0, args);
|
String groupName = ArgumentUtils.handleNameWithSpace(0, args);
|
||||||
String server = ArgumentUtils.handleServer(1, args);
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
String world = ArgumentUtils.handleWorld(2, args);
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
|
|
||||||
|
@ -65,6 +65,14 @@ public class ArgumentUtils {
|
|||||||
return groupName;
|
return groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String handleNameWithSpace(int index, List<String> args) throws ArgumentException {
|
||||||
|
String groupName = args.get(index).toLowerCase();
|
||||||
|
if (ArgumentChecker.checkNameWithSpace(groupName)) {
|
||||||
|
throw new DetailedUsageException();
|
||||||
|
}
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
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()) {
|
if (index < args.size()) {
|
||||||
String bool = args.get(index);
|
String bool = args.get(index);
|
||||||
|
@ -38,6 +38,7 @@ import java.util.regex.Pattern;
|
|||||||
public class Patterns {
|
public class Patterns {
|
||||||
public static final Pattern COMMAND_SEPARATOR = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
public static final Pattern COMMAND_SEPARATOR = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
||||||
public static final Pattern NON_ALPHA_NUMERIC = Pattern.compile("[\\/\\$\\.\\- ]");
|
public static final Pattern NON_ALPHA_NUMERIC = Pattern.compile("[\\/\\$\\.\\- ]");
|
||||||
|
public static final Pattern NON_ALPHA_NUMERIC_SPACE = Pattern.compile("[\\/\\$\\.\\-]");
|
||||||
public static final Pattern NON_USERNAME = Pattern.compile("[^A-Za-z0-9_ ]");
|
public static final Pattern NON_USERNAME = Pattern.compile("[^A-Za-z0-9_ ]");
|
||||||
public static final Pattern SHORTHAND_NODE = Pattern.compile("\\.\\([^.]+\\)");
|
public static final Pattern SHORTHAND_NODE = Pattern.compile("\\.\\([^.]+\\)");
|
||||||
public static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
|
public static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
|
||||||
|
@ -40,6 +40,10 @@ public class ArgumentChecker {
|
|||||||
return (s.length() > 36 || Patterns.NON_ALPHA_NUMERIC.matcher(s).find());
|
return (s.length() > 36 || Patterns.NON_ALPHA_NUMERIC.matcher(s).find());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkNameWithSpace(String s) {
|
||||||
|
return (s.length() > 36 || Patterns.NON_ALPHA_NUMERIC_SPACE.matcher(s).find());
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean checkServer(String s) {
|
public static boolean checkServer(String s) {
|
||||||
return s.toLowerCase().startsWith("r=") || (s.startsWith("(") && s.endsWith(")") && s.contains("|")) || Patterns.NON_ALPHA_NUMERIC.matcher(s).find();
|
return s.toLowerCase().startsWith("r=") || (s.startsWith("(") && s.endsWith(")") && s.contains("|")) || Patterns.NON_ALPHA_NUMERIC.matcher(s).find();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user