From a89a1f88d781f6869cb725df68af3a9bdef41cbe Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 24 Jun 2014 14:26:39 +1200 Subject: [PATCH] Add support for permissions without a underscore --- pom.xml | 2 +- .../utilities/BaseDisguiseCommand.java | 32 +++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 016e0278..2013f419 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 LibsDisguises LibsDisguises - 8.2.6 + 8.2.6-SNAPSHOT src diff --git a/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java b/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java index d33d0f2c..e80ae800 100644 --- a/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java @@ -65,18 +65,24 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { if (perms.get(perm)) { perm = perm.substring(permissionNode.length()); String disguiseType = perm.split("\\.")[0]; - try { - DisguiseType type = DisguiseType.valueOf(disguiseType.toUpperCase()); + DisguiseType dType = null; + for (DisguiseType t : DisguiseType.values()) { + if (t.name().replace("_", "").equalsIgnoreCase(disguiseType.replace("_", ""))) { + dType = t; + break; + } + } + if (dType != null) { HashMap, Boolean> list; - if (singleDisguises.containsKey(type)) { - list = singleDisguises.get(type); + if (singleDisguises.containsKey(dType)) { + list = singleDisguises.get(dType); } else { list = new HashMap, Boolean>(); - singleDisguises.put(type, list); + singleDisguises.put(dType, list); } HashMap, Boolean> map1 = getOptions(perm); list.put(map1.keySet().iterator().next(), map1.values().iterator().next()); - } catch (Exception ex) { + } else { for (DisguiseType type : DisguiseType.values()) { HashMap, Boolean> options = null; Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass(); @@ -122,10 +128,16 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { if (!perms.get(perm)) { perm = perm.substring(permissionNode.length()); String disguiseType = perm.split("\\.")[0]; - try { - DisguiseType type = DisguiseType.valueOf(disguiseType.toUpperCase()); - singleDisguises.remove(type); - } catch (Exception ex) { + DisguiseType dType = null; + for (DisguiseType t : DisguiseType.values()) { + if (t.name().replace("_", "").equalsIgnoreCase(disguiseType.replace("_", ""))) { + dType = t; + break; + } + } + if (dType != null) { + singleDisguises.remove(dType); + } else { for (DisguiseType type : DisguiseType.values()) { boolean foundHim = false; Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass();