From eef044a5a6e688931a914febe020d969c895bf89 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 22 May 2014 08:22:50 +1200 Subject: [PATCH] Fix up multiple options for a single disguise --- .../utilities/BaseDisguiseCommand.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java b/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java index ec1a3073..87821523 100644 --- a/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java @@ -404,24 +404,35 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { private void doCheck(HashSet> optionPermissions, ArrayList usedOptions) throws Exception { if (!optionPermissions.isEmpty()) { + boolean hasPermission = true; for (HashSet perms : optionPermissions) { HashSet cloned = (HashSet) perms.clone(); Iterator itel = cloned.iterator(); while (itel.hasNext()) { String perm = itel.next(); 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(); + if (usedOptions.contains(perm.substring(1))) { + hasPermission = false; + break; + } } } - if (cloned.size() == perms.size() && !cloned.containsAll(usedOptions)) { - throw new Exception(ChatColor.RED + "You do not have the permission to use the option " - + usedOptions.get(usedOptions.size() - 1)); + // 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 " + + usedOptions.get(usedOptions.size() - 1)); + } } }