Added 1.13.2 support, made backwards premium
This commit is contained in:
@@ -78,26 +78,18 @@ public class DisguiseParser {
|
||||
getName = "get" + getName;
|
||||
}
|
||||
|
||||
Method getMethod = null;
|
||||
|
||||
for (Method m : setMethod.getDeclaringClass().getDeclaredMethods()) {
|
||||
if (!m.getName().equals(getName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m.getParameterTypes().length > 0 || m.getReturnType() != setMethod.getParameterTypes()[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
getMethod = m;
|
||||
break;
|
||||
}
|
||||
Method getMethod = setMethod.getDeclaringClass().getMethod(getName);
|
||||
|
||||
if (getMethod == null) {
|
||||
DisguiseUtilities.getLogger().severe(String
|
||||
.format("No such method '%s' when looking for the companion of '%s' in '%s'", getName,
|
||||
setMethod.getName(), setMethod.getDeclaringClass().getSimpleName()));
|
||||
continue;
|
||||
}else if (getMethod.getReturnType() != setMethod.getParameterTypes()[0]){
|
||||
DisguiseUtilities.getLogger().severe(String
|
||||
.format("Invalid return type of '%s' when looking for the companion of '%s' in '%s'", getName,
|
||||
setMethod.getName(), setMethod.getDeclaringClass().getSimpleName()));
|
||||
continue;
|
||||
}
|
||||
|
||||
Object defaultValue = null;
|
||||
|
@@ -9,6 +9,8 @@ import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfoTypes;
|
||||
import me.libraryaddict.disguise.utilities.reflection.DisguiseMethods;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -21,6 +23,7 @@ import java.util.List;
|
||||
|
||||
public class ParamInfoManager {
|
||||
private static List<ParamInfo> paramList;
|
||||
private static DisguiseMethods disguiseMethods;
|
||||
|
||||
public static List<ParamInfo> getParamInfos() {
|
||||
return paramList;
|
||||
@@ -61,12 +64,6 @@ public class ParamInfoManager {
|
||||
if (!method.getName().toLowerCase().equals(methodName.toLowerCase()))
|
||||
continue;
|
||||
|
||||
if (method.getParameterTypes().length != 1)
|
||||
continue;
|
||||
|
||||
if (method.getAnnotation(Deprecated.class) != null)
|
||||
continue;
|
||||
|
||||
return getParamInfo(method.getParameterTypes()[0]);
|
||||
}
|
||||
|
||||
@@ -75,6 +72,7 @@ public class ParamInfoManager {
|
||||
|
||||
static {
|
||||
paramList = new ParamInfoTypes().getParamInfos();
|
||||
disguiseMethods = new DisguiseMethods();
|
||||
|
||||
//paramList.sort((o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()));
|
||||
}
|
||||
@@ -84,7 +82,7 @@ public class ParamInfoManager {
|
||||
return new Method[0];
|
||||
}
|
||||
|
||||
ArrayList<Method> methods = new ArrayList<>(Arrays.asList(watcherClass.getMethods()));
|
||||
ArrayList<Method> methods = new ArrayList<>(disguiseMethods.getMethods(watcherClass));
|
||||
|
||||
Iterator<Method> itel = methods.iterator();
|
||||
|
||||
@@ -93,20 +91,8 @@ public class ParamInfoManager {
|
||||
|
||||
if (!ReflectionManager.isSupported(method)) {
|
||||
itel.remove();
|
||||
} else if (method.getParameterTypes().length != 1) {
|
||||
itel.remove();
|
||||
} else if (method.getName().startsWith("get")) {
|
||||
itel.remove();
|
||||
} else if (method.isAnnotationPresent(Deprecated.class)) {
|
||||
itel.remove();
|
||||
} else if (getParamInfo(method.getParameterTypes()[0]) == null) {
|
||||
itel.remove();
|
||||
} else if (!method.getReturnType().equals(Void.TYPE)) {
|
||||
itel.remove();
|
||||
} else if (method.getName().equals("removePotionEffect")) {
|
||||
itel.remove();
|
||||
} else if (!FlagWatcher.class.isAssignableFrom(method.getDeclaringClass())) {
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@ import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||
import me.libraryaddict.disguise.utilities.parser.params.types.ParamInfoEnum;
|
||||
import me.libraryaddict.disguise.utilities.parser.params.types.base.*;
|
||||
import me.libraryaddict.disguise.utilities.parser.params.types.custom.*;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -41,8 +42,12 @@ public class ParamInfoTypes {
|
||||
|
||||
paramInfos.add(new ParamInfoEnum(Villager.Profession.class, "Villager Profession",
|
||||
"View all the professions you can set on a Villager and Zombie Villager"));
|
||||
paramInfos.add(new ParamInfoEnum(Villager.Type.class, "Villager Biome",
|
||||
"View all the biomes you can set on a Villager and Zombie Villager"));
|
||||
|
||||
if (NmsVersion.v1_14.isSupported()) {
|
||||
paramInfos.add(new ParamInfoEnum(Villager.Type.class, "Villager Biome",
|
||||
"View all the biomes you can set on a Villager and Zombie Villager"));
|
||||
}
|
||||
|
||||
paramInfos.add(new ParamInfoEnum(BlockFace.class, "Direction", "Direction (North, East, South, West, Up, Down)",
|
||||
"View the directions usable on player setSleeping and shulker direction",
|
||||
Arrays.copyOf(BlockFace.values(), 6)));
|
||||
@@ -62,12 +67,15 @@ public class ParamInfoTypes {
|
||||
paramInfos.add(new ParamInfoEnum(DyeColor.class, "DyeColor", "Dye colors of many different colors"));
|
||||
paramInfos.add(new ParamInfoEnum(Horse.Style.class, "Horse Style",
|
||||
"Horse style which is the patterns on the horse"));
|
||||
paramInfos.add(new ParamInfoEnum(EntityPose.class, "EntityPose", "The pose the entity should strike"));
|
||||
paramInfos.add(new ParamInfoEnum(Cat.Type.class, "Cat Type", "The type of cat"));
|
||||
paramInfos.add(new ParamInfoEnum(Fox.Type.class, "Fox Type", "The type of fox"));
|
||||
paramInfos.add(new ParamInfoEnum(Panda.Gene.class, "Panda Gene", "The panda gene type"));
|
||||
paramInfos.add(new ParamInfoEnum(MushroomCow.Variant.class, "Mushroom Cow Variant",
|
||||
"The different variants for mushroom cows"));
|
||||
|
||||
if (NmsVersion.v1_14.isSupported()) {
|
||||
paramInfos.add(new ParamInfoEnum(EntityPose.class, "EntityPose", "The pose the entity should strike"));
|
||||
paramInfos.add(new ParamInfoEnum(Cat.Type.class, "Cat Type", "The type of cat"));
|
||||
paramInfos.add(new ParamInfoEnum(Fox.Type.class, "Fox Type", "The type of fox"));
|
||||
paramInfos.add(new ParamInfoEnum(Panda.Gene.class, "Panda Gene", "The panda gene type"));
|
||||
paramInfos.add(new ParamInfoEnum(MushroomCow.Variant.class, "Mushroom Cow Variant",
|
||||
"The different variants for mushroom cows"));
|
||||
}
|
||||
|
||||
// Register custom types
|
||||
paramInfos.add(new ParamInfoEulerAngle(EulerAngle.class, "Euler Angle", "Euler Angle (X,Y,Z)",
|
||||
|
Reference in New Issue
Block a user