Fix up multiple options for a single disguise
This commit is contained in:
parent
ccb512a20b
commit
eef044a5a6
@ -404,26 +404,37 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
|
|
||||||
private void doCheck(HashSet<HashSet<String>> optionPermissions, ArrayList<String> usedOptions) throws Exception {
|
private void doCheck(HashSet<HashSet<String>> optionPermissions, ArrayList<String> usedOptions) throws Exception {
|
||||||
if (!optionPermissions.isEmpty()) {
|
if (!optionPermissions.isEmpty()) {
|
||||||
|
boolean hasPermission = true;
|
||||||
for (HashSet<String> perms : optionPermissions) {
|
for (HashSet<String> perms : optionPermissions) {
|
||||||
HashSet<String> cloned = (HashSet<String>) perms.clone();
|
HashSet<String> cloned = (HashSet<String>) perms.clone();
|
||||||
Iterator<String> itel = cloned.iterator();
|
Iterator<String> itel = cloned.iterator();
|
||||||
while (itel.hasNext()) {
|
while (itel.hasNext()) {
|
||||||
String perm = itel.next();
|
String perm = itel.next();
|
||||||
if (perm.startsWith("-")) {
|
if (perm.startsWith("-")) {
|
||||||
if (usedOptions.contains(perm.substring(1))) {
|
|
||||||
throw new Exception(ChatColor.RED + "You do not have the permission to use the option "
|
|
||||||
+ perm.substring(1));
|
|
||||||
}
|
|
||||||
itel.remove();
|
itel.remove();
|
||||||
|
if (usedOptions.contains(perm.substring(1))) {
|
||||||
|
hasPermission = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cloned.size() == perms.size() && !cloned.containsAll(usedOptions)) {
|
}
|
||||||
|
// If this wasn't modified by the above check
|
||||||
|
if (perms.size() == cloned.size()) {
|
||||||
|
// If there is a option used that the perms don't allow
|
||||||
|
if (!perms.containsAll(usedOptions)) {
|
||||||
|
hasPermission = false;
|
||||||
|
} else {
|
||||||
|
// The perms allow it. Return true
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasPermission) {
|
||||||
throw new Exception(ChatColor.RED + "You do not have the permission to use the option "
|
throw new Exception(ChatColor.RED + "You do not have the permission to use the option "
|
||||||
+ usedOptions.get(usedOptions.size() - 1));
|
+ usedOptions.get(usedOptions.size() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private Exception parseToException(String expectedValue, String receivedInstead, String methodName) {
|
private Exception parseToException(String expectedValue, String receivedInstead, String methodName) {
|
||||||
return new Exception(ChatColor.RED + "Expected " + ChatColor.GREEN + expectedValue + ChatColor.RED + ", received "
|
return new Exception(ChatColor.RED + "Expected " + ChatColor.GREEN + expectedValue + ChatColor.RED + ", received "
|
||||||
|
Loading…
Reference in New Issue
Block a user