mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-13 15:16:50 +01:00
Add the ability to negate options instead of giving options
This commit is contained in:
parent
09458d8e65
commit
d4461f7ade
2
pom.xml
2
pom.xml
@ -64,7 +64,7 @@
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>7.8</version>
|
||||
<version>7.8-SNAPSHOT</version>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
@ -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);
|
||||
|
@ -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<Method> getUsableMethods(DisguiseType disguiseType, CommandSender commandSender) {
|
||||
ArrayList<Method> methods = getSettableMethods(disguiseType);
|
||||
ArrayList<String> allowedDisguises = this.getAllowedDisguises(commandSender);
|
||||
}
|
||||
|
||||
private ArrayList<Method> getSettableMethods(DisguiseType disguiseType) {
|
||||
ArrayList<Method> methods = new ArrayList<Method>();
|
||||
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<HashSet<String>> optionPermissions, HashSet<String> usedOptions) throws Exception {
|
||||
if (!optionPermissions.isEmpty()) {
|
||||
for (HashSet<String> perms : optionPermissions) {
|
||||
if (!perms.containsAll(usedOptions)) {
|
||||
HashSet<String> cloned = (HashSet<String>) perms.clone();
|
||||
Iterator<String> 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]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user