Add libsdisguises.command.valid.optionstoset

This commit is contained in:
libraryaddict 2020-04-20 22:34:03 +12:00
parent e9a968fe7b
commit 0945fe866c
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4

View File

@ -138,9 +138,10 @@ public class DisguisePermissions {
String disguiseName = split[2];
DisguisePerm dPerm = DisguiseParser.getDisguisePerm(disguiseName);
HashMap<String, Boolean> options = getOptions(permission);
DisguisePerm dPerm = DisguiseParser.getDisguisePerm(disguiseName);
// If this refers to a specific disguise
if (dPerm != null) {
return new ParsedPermission(new DisguisePerm[]{dPerm}, options, (byte) 0, split[1].equals("*"));
@ -233,7 +234,16 @@ public class DisguisePermissions {
List<ParsedPermission> list = new ArrayList<>();
ArrayList<String> valids = new ArrayList<>();
for (Map.Entry<String, Boolean> entry : permissions.entrySet()) {
String key = entry.getKey();
if (key.split("\\.").length > 2 && key.split("\\.")[2].equalsIgnoreCase("valid")) {
valids.add(key);
continue;
}
ParsedPermission temp = parsePermission(entry.getKey());
if (temp == null) {
@ -245,6 +255,20 @@ public class DisguisePermissions {
list.add(temp);
}
for (String valid : valids) {
HashMap<String, Boolean> options = getOptions(valid);
String key = valid.split("\\.")[1];
if (!key.equals("*") && !key.equalsIgnoreCase(commandName)){
continue;
}
for (ParsedPermission perms : list) {
perms.options.putAll(options);
}
}
// Sorted from 5 to 0 where "*" is first and "Cow" is last
// Negated permissions are last in each inheritance, so false, false, true, true
@ -384,7 +408,7 @@ public class DisguisePermissions {
if (disguiseType.isMisc()) {
return 3;
}
} else if (permissionName.equals("custom")) {
} else if (permissionName.equals("custom")) {
if (disguiseType.isMisc()) {
return 3;
}