Add support for permissions without a underscore

This commit is contained in:
libraryaddict 2014-06-24 14:26:39 +12:00
parent f25f6d3ee3
commit a89a1f88d7
2 changed files with 23 additions and 11 deletions

View file

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>LibsDisguises</groupId> <groupId>LibsDisguises</groupId>
<artifactId>LibsDisguises</artifactId> <artifactId>LibsDisguises</artifactId>
<version>8.2.6</version> <version>8.2.6-SNAPSHOT</version>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>

View file

@ -65,18 +65,24 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
if (perms.get(perm)) { if (perms.get(perm)) {
perm = perm.substring(permissionNode.length()); perm = perm.substring(permissionNode.length());
String disguiseType = perm.split("\\.")[0]; String disguiseType = perm.split("\\.")[0];
try { DisguiseType dType = null;
DisguiseType type = DisguiseType.valueOf(disguiseType.toUpperCase()); for (DisguiseType t : DisguiseType.values()) {
if (t.name().replace("_", "").equalsIgnoreCase(disguiseType.replace("_", ""))) {
dType = t;
break;
}
}
if (dType != null) {
HashMap<ArrayList<String>, Boolean> list; HashMap<ArrayList<String>, Boolean> list;
if (singleDisguises.containsKey(type)) { if (singleDisguises.containsKey(dType)) {
list = singleDisguises.get(type); list = singleDisguises.get(dType);
} else { } else {
list = new HashMap<ArrayList<String>, Boolean>(); list = new HashMap<ArrayList<String>, Boolean>();
singleDisguises.put(type, list); singleDisguises.put(dType, list);
} }
HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm); HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm);
list.put(map1.keySet().iterator().next(), map1.values().iterator().next()); list.put(map1.keySet().iterator().next(), map1.values().iterator().next());
} catch (Exception ex) { } else {
for (DisguiseType type : DisguiseType.values()) { for (DisguiseType type : DisguiseType.values()) {
HashMap<ArrayList<String>, Boolean> options = null; HashMap<ArrayList<String>, Boolean> options = null;
Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass(); Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass();
@ -122,10 +128,16 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
if (!perms.get(perm)) { if (!perms.get(perm)) {
perm = perm.substring(permissionNode.length()); perm = perm.substring(permissionNode.length());
String disguiseType = perm.split("\\.")[0]; String disguiseType = perm.split("\\.")[0];
try { DisguiseType dType = null;
DisguiseType type = DisguiseType.valueOf(disguiseType.toUpperCase()); for (DisguiseType t : DisguiseType.values()) {
singleDisguises.remove(type); if (t.name().replace("_", "").equalsIgnoreCase(disguiseType.replace("_", ""))) {
} catch (Exception ex) { dType = t;
break;
}
}
if (dType != null) {
singleDisguises.remove(dType);
} else {
for (DisguiseType type : DisguiseType.values()) { for (DisguiseType type : DisguiseType.values()) {
boolean foundHim = false; boolean foundHim = false;
Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass(); Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass();