diff --git a/pom.xml b/pom.xml index 68ddd903..83fab18e 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 3.0.0-SNAPSHOT - 7.8 + 7.8-SNAPSHOT diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 3f033f17..883fa0a1 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -193,8 +193,12 @@ public class LibsDisguises extends JavaPlugin { } } DisguiseValues disguiseValues = new DisguiseValues(disguiseType, nmsEntity.getClass(), entitySize); - for (WrappedWatchableObject watch : WrappedDataWatcher.getEntityWatcher(bukkitEntity).getWatchableObjects()) + for (WrappedWatchableObject watch : WrappedDataWatcher.getEntityWatcher(bukkitEntity).getWatchableObjects()) { disguiseValues.setMetaValue(watch.getIndex(), watch.getValue()); + // Uncomment when I need to find the new datawatcher values for a class.. + // System.out.print("Disguise: " + disguiseType + ", ID: " + watch.getIndex() + ", Class: " + // + (watch.getValue() == null ? "null" : watch.getValue()) + ", Value: " + watch.getValue()); + } DisguiseSound sound = DisguiseSound.getType(disguiseType.name()); if (sound != null) { Float soundStrength = ReflectionManager.getSoundModifier(nmsEntity); diff --git a/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java b/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java index e76bce7d..10815c82 100644 --- a/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java @@ -4,6 +4,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; @@ -371,10 +372,50 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { return disguise; } + /* private ArrayList getUsableMethods(DisguiseType disguiseType, CommandSender commandSender) { + ArrayList methods = getSettableMethods(disguiseType); + ArrayList allowedDisguises = this.getAllowedDisguises(commandSender); + } + + private ArrayList getSettableMethods(DisguiseType disguiseType) { + ArrayList methods = new ArrayList(); + String[] acceptableParams = new String[] { "String", "boolean", "int", "float", "double", "AnimalColor", "ItemStack", + "ItemStack[]", "Style", "Color", "Type", "Profession", "PotionEffectType" }; + try { + for (Method method : disguiseType.getWatcherClass().getMethods()) { + if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1 + && method.getAnnotation(Deprecated.class) == null) { + Class c = method.getParameterTypes()[0]; + for (String acceptable : acceptableParams) { + if (c.getSimpleName().equals(acceptable)) { + methods.add(method); + break; + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return methods; + }*/// // + private void doCheck(HashSet> optionPermissions, HashSet usedOptions) throws Exception { if (!optionPermissions.isEmpty()) { for (HashSet perms : optionPermissions) { - if (!perms.containsAll(usedOptions)) { + 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 (cloned.size() == perms.size() && !cloned.containsAll(usedOptions)) { throw new Exception(ChatColor.RED + "You do not have the permission to use the option " + usedOptions.toArray(new String[usedOptions.size()])[usedOptions.size() - 1]); }