Process shorthand in server/world names

This commit is contained in:
Luck 2016-08-19 19:36:04 +01:00
parent 0c12eebe6f
commit 9424d2d2ba
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 19 additions and 6 deletions

View File

@ -701,15 +701,28 @@ public abstract class PermissionHolder {
}
private boolean matches(String entry, String possibleRegex) {
if (!possibleRegex.toLowerCase().startsWith("r=") || !plugin.getConfiguration().getApplyRegex()) {
return entry.equalsIgnoreCase(possibleRegex);
if (possibleRegex.toLowerCase().startsWith("r=") && plugin.getConfiguration().getApplyRegex()) {
Pattern p = Patterns.compile(possibleRegex.substring(2));
if (p == null) {
return false;
}
return p.matcher(entry).matches();
}
Pattern p = Patterns.compile(possibleRegex.substring(2));
if (p == null) {
if (possibleRegex.startsWith("(") && possibleRegex.endsWith(")") && possibleRegex.contains("|")) {
final String bits = possibleRegex.substring(1, possibleRegex.length() - 1);
String[] parts = Patterns.VERTICAL_BAR.split(bits);
for (String s : parts) {
if (s.equalsIgnoreCase(entry)) {
return true;
}
}
return false;
}
return p.matcher(entry).matches();
return entry.equalsIgnoreCase(possibleRegex);
}
private Map<String, Boolean> applyRegex(Map<String, Boolean> input, List<String> possibleNodes) {

View File

@ -37,7 +37,7 @@ public class ArgumentChecker {
}
public static boolean checkServer(String s) {
return s.toLowerCase().startsWith("r=") || 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();
}
public static boolean checkNode(String s) {