More work, vaguely remember fixing a bug

This commit is contained in:
libraryaddict 2017-06-22 23:36:45 +12:00
parent fc8efdd00c
commit 82435b7067
6 changed files with 94 additions and 82 deletions

View File

@ -78,8 +78,6 @@ public class LibsDisguises extends JavaPlugin {
PacketsManager.addPacketListeners(); PacketsManager.addPacketListeners();
TranslateType.MESSAGES.name(); // Call the static loader
listener = new DisguiseListener(this); listener = new DisguiseListener(this);
Bukkit.getPluginManager().registerEvents(listener, this); Bukkit.getPluginManager().registerEvents(listener, this);
@ -322,30 +320,30 @@ public class LibsDisguises extends JavaPlugin {
MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex()); MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex());
if (flagType == null) { if (flagType == null) {
System.err.println( System.err.println("Error finding the FlagType for " + disguiseType.name() + "! Index " + watch
"Error finding the FlagType for " + disguiseType.name() + "! Index " + watch.getIndex() + " can't be found!"); .getIndex() + " can't be found!");
System.err.println( System.err.println("Value is " + watch.getRawValue() + " (" + watch.getRawValue()
"Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName()); .getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName());
System.err.println("Lib's Disguises will continue to load, but this will not work properly!"); System.err.println("Lib's Disguises will continue to load, but this will not work properly!");
continue; continue;
} }
indexes.remove(flagType); indexes.remove(flagType);
if (ReflectionManager.convertInvalidItem( if (ReflectionManager.convertInvalidItem(flagType.getDefault()).getClass() != ReflectionManager
flagType.getDefault()).getClass() != ReflectionManager.convertInvalidItem( .convertInvalidItem(watch.getValue()).getClass()) {
watch.getValue()).getClass()) { System.err.println("Mismatch of FlagType's for " + disguiseType.name() + "! Index " + watch
System.err.println( .getIndex() + " has the wrong classtype!");
"Mismatch of FlagType's for " + disguiseType.name() + "! Index " + watch.getIndex() + " has the wrong classtype!"); System.err.println("Value is " + watch.getRawValue() + " (" + watch.getRawValue()
System.err.println( .getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass
"Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName() + " which doesn't match up with " + flagType.getDefault().getClass()); .getSimpleName() + " which doesn't match up with " + flagType.getDefault().getClass());
System.err.println("Lib's Disguises will continue to load, but this will not work properly!"); System.err.println("Lib's Disguises will continue to load, but this will not work properly!");
} }
} }
for (MetaIndex index : indexes) { for (MetaIndex index : indexes) {
System.out.println( System.out.println(disguiseType + " has MetaIndex remaining! " + index.getFlagWatcher()
disguiseType + " has MetaIndex remaining! " + index.getFlagWatcher().getSimpleName() + " at index " + index.getIndex()); .getSimpleName() + " at index " + index.getIndex());
} }
DisguiseSound sound = DisguiseSound.getType(disguiseType.name()); DisguiseSound sound = DisguiseSound.getType(disguiseType.name());
@ -374,12 +372,12 @@ public class LibsDisguises extends JavaPlugin {
disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity)); disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity));
} }
catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex) { catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex) {
System.out.print( System.out.print("[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType
"[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType.name() + "!"); .name() + "!");
System.out.print( System.out
"[LibsDisguises] Before reporting this error, " + "please make sure you are using the latest version of LibsDisguises and ProtocolLib."); .print("[LibsDisguises] Before reporting this error, " + "please make sure you are using the latest version of LibsDisguises and ProtocolLib.");
System.out.print( System.out
"[LibsDisguises] Development builds are available at (ProtocolLib) " + "http://ci.dmulloy2.net/job/ProtocolLib/ and (LibsDisguises) http://server.o2gaming.com:8080/job/LibsDisguises%201.9+/"); .print("[LibsDisguises] Development builds are available at (ProtocolLib) " + "http://ci.dmulloy2.net/job/ProtocolLib/ and (LibsDisguises) http://server.o2gaming.com:8080/job/LibsDisguises%201.9+/");
ex.printStackTrace(); ex.printStackTrace();
} }

View File

@ -57,11 +57,12 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
return true; return true;
} }
if (args[0].equalsIgnoreCase("entitytype") || args[0].equalsIgnoreCase("entitytypes")) { if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType")) || args[0]
.equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType") + "s")) {
ArrayList<String> classes = new ArrayList<>(); ArrayList<String> classes = new ArrayList<>();
for (Class c : validClasses) { for (Class c : validClasses) {
classes.add(c.getSimpleName()); classes.add(TranslateType.DISGUISES.get(c.getSimpleName()));
} }
Collections.sort(classes); Collections.sort(classes);
@ -77,7 +78,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
if (!isNumeric(args[0])) { if (!isNumeric(args[0])) {
for (Class c : validClasses) { for (Class c : validClasses) {
if (c.getSimpleName().equalsIgnoreCase(args[0])) { if (TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0])) {
entityClass = c; entityClass = c;
starting = 1; starting = 1;
break; break;
@ -208,7 +209,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
if (args.length == 0) { if (args.length == 0) {
for (Class<? extends Entity> entityClass : validClasses) { for (Class<? extends Entity> entityClass : validClasses) {
tabs.add(entityClass.getSimpleName()); tabs.add(TranslateType.DISGUISES.get(entityClass.getSimpleName()));
} }
return filterTabs(tabs, origArgs); return filterTabs(tabs, origArgs);
@ -218,7 +219,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
if (!isNumeric(args[0])) { if (!isNumeric(args[0])) {
for (Class c : validClasses) { for (Class c : validClasses) {
if (!c.getSimpleName().equalsIgnoreCase(args[0])) if (!TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0]))
continue; continue;
starting = 2; starting = 2;

View File

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.mojang.authlib.GameProfile;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -27,6 +28,7 @@ import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
import me.libraryaddict.disguise.disguisetypes.MobDisguise; import me.libraryaddict.disguise.disguisetypes.MobDisguise;
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
import me.libraryaddict.disguise.disguisetypes.RabbitType; import me.libraryaddict.disguise.disguisetypes.RabbitType;
import sun.reflect.Reflection;
public class DisguiseParser { public class DisguiseParser {
public static class DisguiseParseException extends Exception { public static class DisguiseParseException extends Exception {
@ -125,14 +127,14 @@ public class DisguiseParser {
} }
} }
private static Object callValueOf(Class<?> param, String valueString, String methodName, private static Object callValueOf(Class<?> param, String valueString,
String description) throws DisguiseParseException { String methodName) throws DisguiseParseException {
Object value; Object value;
try { try {
value = param.getMethod("valueOf", String.class).invoke(null, valueString.toUpperCase()); value = param.getMethod("valueOf", String.class).invoke(null, valueString.toUpperCase());
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException(description, valueString, methodName); throw parseToException(param, valueString, methodName);
} }
return value; return value;
} }
@ -189,7 +191,7 @@ public class DisguiseParser {
} }
if (name.equalsIgnoreCase("p")) if (name.equalsIgnoreCase("p"))
return getDisguisePerm("player"); return getDisguisePerm(DisguiseType.PLAYER.toReadable());
return null; return null;
} }
@ -530,10 +532,11 @@ public class DisguiseParser {
boolean adult = true; boolean adult = true;
if (args.length > 1) { if (args.length > 1) {
if (args[1].equalsIgnoreCase("baby") || args[1].equalsIgnoreCase("adult")) { if (args[1].equalsIgnoreCase(TranslateType.DISGUISE_OPTIONS.get("baby")) || args[1]
.equalsIgnoreCase(TranslateType.DISGUISE_OPTIONS.get("adult"))) {
usedOptions.add("setbaby"); usedOptions.add("setbaby");
doCheck(sender, optionPermissions, usedOptions); doCheck(sender, optionPermissions, usedOptions);
adult = args[1].equalsIgnoreCase("adult"); adult = args[1].equalsIgnoreCase(TranslateType.DISGUISE_OPTIONS.get("adult"));
toSkip++; toSkip++;
} }
@ -660,7 +663,8 @@ public class DisguiseParser {
Method[] methods = ReflectionFlagWatchers.getDisguiseWatcherMethods(disguise.getWatcher().getClass()); Method[] methods = ReflectionFlagWatchers.getDisguiseWatcherMethods(disguise.getWatcher().getClass());
for (int i = 0; i < args.length; i += 2) { for (int i = 0; i < args.length; i += 2) {
String methodName = TranslateType.DISGUISE_OPTIONS.reverseGet(args[i]); String methodNameRaw;
String methodName = TranslateType.DISGUISE_OPTIONS.reverseGet(methodNameRaw = args[i]);
String valueString = TranslateType.DISGUISE_OPTIONS_PARAMETERS String valueString = TranslateType.DISGUISE_OPTIONS_PARAMETERS
.reverseGet(args.length - 1 == i ? null : args[i + 1]); .reverseGet(args.length - 1 == i ? null : args[i + 1]);
Method methodToUse = null; Method methodToUse = null;
@ -678,7 +682,7 @@ public class DisguiseParser {
methodToUse = entry.getKey(); methodToUse = entry.getKey();
c = entry.getValue(); c = entry.getValue();
methodName = methodToUse.getName(); methodName = TranslateType.DISGUISE_OPTIONS.reverseGet(methodNameRaw = methodToUse.getName());
Class<?>[] types = methodToUse.getParameterTypes(); Class<?>[] types = methodToUse.getParameterTypes();
Class param = types[0]; Class param = types[0];
@ -688,14 +692,14 @@ public class DisguiseParser {
if (isInteger(valueString)) { if (isInteger(valueString)) {
value = Integer.parseInt(valueString); value = Integer.parseInt(valueString);
} else { } else {
throw parseToException("number", valueString, methodName); throw parseToException(param, valueString, methodName);
} }
} else if (WrappedGameProfile.class == param && valueString.length() > 20) { } else if (WrappedGameProfile.class == param && valueString.length() > 20) {
try { try {
value = ReflectionManager.parseGameProfile(valueString); value = ReflectionManager.parseGameProfile(valueString);
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException("gameprofile", valueString, methodName); throw parseToException(GameProfile.class, valueString, methodName);
} }
} else if (float.class == param || double.class == param) { } else if (float.class == param || double.class == param) {
// Parse to number // Parse to number
@ -707,10 +711,10 @@ public class DisguiseParser {
value = (double) obj; value = (double) obj;
} }
} else { } else {
throw parseToException("number.0", valueString, methodName); throw parseToException(param, valueString, methodName);
} }
} else if (param == String.class) { } else if (param == String.class) {
if (methodName.equalsIgnoreCase("setskin") && valueString.length() > 20) { if (methodNameRaw.equalsIgnoreCase("setskin") && valueString.length() > 20) {
value = valueString; value = valueString;
} else { } else {
// Parse to string // Parse to string
@ -722,18 +726,18 @@ public class DisguiseParser {
value = AnimalColor.valueOf(valueString.toUpperCase()); value = AnimalColor.valueOf(valueString.toUpperCase());
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException("animal color", valueString, methodName); throw parseToException(param, valueString, methodName);
} }
} else if (param == Llama.Color.class) { } else if (param == Llama.Color.class) {
try { try {
value = Llama.Color.valueOf(valueString.toUpperCase()); value = Llama.Color.valueOf(valueString.toUpperCase());
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException("llama color", valueString, methodName); throw parseToException(param, valueString, methodName);
} }
} else if (param == ItemStack.class) { } else if (param == ItemStack.class) {
// Parse to itemstack // Parse to itemstack
value = parseToItemstack(methodName, valueString); value = parseToItemstack(param, methodName, valueString);
} else if (param == ItemStack[].class) { } else if (param == ItemStack[].class) {
// Parse to itemstack array // Parse to itemstack array
ItemStack[] items = new ItemStack[4]; ItemStack[] items = new ItemStack[4];
@ -743,39 +747,35 @@ public class DisguiseParser {
if (split.length == 4) { if (split.length == 4) {
for (int a = 0; a < 4; a++) { for (int a = 0; a < 4; a++) {
try { try {
items[a] = parseToItemstack(methodName, split[a]); items[a] = parseToItemstack(param, methodName, split[a]);
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException( throw parseToException(param, valueString, methodName);
"item ID,ID,ID,ID" + ChatColor.RED + " or " + ChatColor.GREEN + "ID:Data,ID:Data,ID:Data,ID:Data combo",
valueString, methodName);
} }
} }
} else { } else {
throw parseToException( throw parseToException(param, valueString, methodName);
"item ID,ID,ID,ID" + ChatColor.RED + " or " + ChatColor.GREEN + "ID:Data,ID:Data,ID:Data,ID:Data combo",
valueString, methodName);
} }
value = items; value = items;
} else if (param.getSimpleName().equals("Color")) { } else if (param.getSimpleName().equals("Color")) {
// Parse to horse color // Parse to horse color
value = callValueOf(param, valueString, methodName, "a horse color"); value = callValueOf(param, valueString, methodName);
} else if (param.getSimpleName().equals("Style")) { } else if (param.getSimpleName().equals("Style")) {
// Parse to horse style // Parse to horse style
value = callValueOf(param, valueString, methodName, "a horse style"); value = callValueOf(param, valueString, methodName);
} else if (param.getSimpleName().equals("Profession")) { } else if (param.getSimpleName().equals("Profession")) {
// Parse to villager profession // Parse to villager profession
value = callValueOf(param, valueString, methodName, "a villager profession"); value = callValueOf(param, valueString, methodName);
} else if (param.getSimpleName().equals("Art")) { } else if (param.getSimpleName().equals("Art")) {
// Parse to art type // Parse to art type
value = callValueOf(param, valueString, methodName, "a painting art"); value = callValueOf(param, valueString, methodName);
} else if (param.getSimpleName().equals("Type")) { } else if (param.getSimpleName().equals("Type")) {
// Parse to ocelot type // Parse to ocelot type
value = callValueOf(param, valueString, methodName, "a ocelot type"); value = callValueOf(param, valueString, methodName);
} else if (param.getSimpleName().equals("TreeSpecies")) { } else if (param.getSimpleName().equals("TreeSpecies")) {
// Parse to ocelot type // Parse to ocelot type
value = callValueOf(param, valueString, methodName, "a tree species"); value = callValueOf(param, valueString, methodName);
} else if (param == PotionEffectType.class) { } else if (param == PotionEffectType.class) {
// Parse to potion effect // Parse to potion effect
try { try {
@ -792,7 +792,7 @@ public class DisguiseParser {
value = potionType; value = potionType;
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException("a potioneffect type", valueString, methodName); throw parseToException(param, valueString, methodName);
} }
} else if (param == int[].class) { } else if (param == int[].class) {
String[] split = valueString.split(","); String[] split = valueString.split(",");
@ -804,7 +804,7 @@ public class DisguiseParser {
values[b] = Integer.parseInt(split[b]); values[b] = Integer.parseInt(split[b]);
} }
catch (NumberFormatException ex) { catch (NumberFormatException ex) {
throw parseToException("Number,Number,Number...", valueString, methodName); throw parseToException(param, valueString, methodName);
} }
} }
@ -820,8 +820,7 @@ public class DisguiseParser {
value = face; value = face;
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException("a direction (north, east, south, west, up, down)", valueString, throw parseToException(param, valueString, methodName);
methodName);
} }
} else if (param == RabbitType.class) { } else if (param == RabbitType.class) {
try { try {
@ -838,8 +837,7 @@ public class DisguiseParser {
} }
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException("rabbit type (white, brown, patches...)", valueString, throw parseToException(param, valueString, methodName);
methodName);
} }
} else if (param == BlockPosition.class) { } else if (param == BlockPosition.class) {
try { try {
@ -851,10 +849,10 @@ public class DisguiseParser {
Integer.parseInt(split[2])); Integer.parseInt(split[2]));
} }
catch (Exception ex) { catch (Exception ex) {
throw parseToException("three numbers Number,Number,Number", valueString, methodName); throw parseToException(param, valueString, methodName);
} }
} else if (param.getName().equals("org.bukkit.entity.Parrot$Variant")) { } else if (param.getName().equals("org.bukkit.entity.Parrot$Variant")) {
value = callValueOf(param, valueString, methodName, "a parrot color"); value = callValueOf(param, valueString, methodName);
} }
} }
@ -862,13 +860,15 @@ public class DisguiseParser {
if (valueString == null) { if (valueString == null) {
value = true; value = true;
i--; i--;
} else if (valueString.equalsIgnoreCase("true")) { } else if (valueString
.equalsIgnoreCase(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("true"))) {
value = true; value = true;
} else if (valueString.equalsIgnoreCase("false")) { } else if (valueString
.equalsIgnoreCase(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("false"))) {
value = false; value = false;
} else { } else {
if (getMethod(methods, valueString, 0) == null) { if (getMethod(methods, valueString, 0) == null) {
throw parseToException("true/false", valueString, methodName); throw parseToException(param, valueString, methodName);
} else { } else {
value = true; value = true;
i--; i--;
@ -901,8 +901,8 @@ public class DisguiseParser {
throw new DisguiseParseException(LibsMsg.PARSE_NO_OPTION_VALUE, methodName); throw new DisguiseParseException(LibsMsg.PARSE_NO_OPTION_VALUE, methodName);
} }
if (!usedOptions.contains(methodName.toLowerCase())) { if (!usedOptions.contains(methodNameRaw.toLowerCase())) {
usedOptions.add(methodName.toLowerCase()); usedOptions.add(methodNameRaw.toLowerCase());
} }
doCheck(sender, optionPermissions, usedOptions); doCheck(sender, optionPermissions, usedOptions);
@ -915,12 +915,12 @@ public class DisguiseParser {
} }
} }
private static DisguiseParseException parseToException(String expectedValue, String receivedInstead, private static DisguiseParseException parseToException(Class paramType, String receivedInstead, String methodName) {
String methodName) { return new DisguiseParseException(LibsMsg.PARSE_EXPECTED_RECEIVED,
return new DisguiseParseException(LibsMsg.PARSE_EXPECTED_RECEIVED, expectedValue, receivedInstead, methodName); ReflectionFlagWatchers.getParamInfo(paramType).getName(), receivedInstead, methodName);
} }
private static ItemStack parseToItemstack(String method, String string) throws DisguiseParseException { private static ItemStack parseToItemstack(Class param, String method, String string) throws DisguiseParseException {
String[] split = string.split(":", -1); String[] split = string.split(":", -1);
int itemId = -1; int itemId = -1;
@ -942,16 +942,16 @@ public class DisguiseParser {
if (isInteger(split[1])) { if (isInteger(split[1])) {
itemDura = Short.parseShort(split[1]); itemDura = Short.parseShort(split[1]);
} else { } else {
throw parseToException("item ID:Durability combo", string, "%s"); throw parseToException(param, string, "%s");
} }
} }
return new ItemStack(itemId, 1, itemDura); return new ItemStack(itemId, 1, itemDura);
} else { } else {
if (split.length == 1) { if (split.length == 1) {
throw parseToException("item ID", string, "%s"); throw parseToException(param, string, "%s");
} else { } else {
throw parseToException("item ID:Durability combo", string, "%s"); throw parseToException(param, string, "%s");
} }
} }
} }

View File

@ -150,7 +150,8 @@ public class ReflectionFlagWatchers {
new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots"); new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots");
new ParamInfo(Villager.Profession.class, "Villager Profession", new ParamInfo(Villager.Profession.class, "Villager Profession",
"View all the professions you can set on a villager"); "View all the professions you can set on a villager");
new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 4), "Direction", new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 6), "Direction (North, East, South, West, " +
"Up, Down)",
"View the four directions usable on player setSleeping disguise"); "View the four directions usable on player setSleeping disguise");
new ParamInfo(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into"); new ParamInfo(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into");
new ParamInfo(TreeSpecies.class, "Tree Species", "View the different types of tree species"); new ParamInfo(TreeSpecies.class, "Tree Species", "View the different types of tree species");
@ -177,9 +178,10 @@ public class ReflectionFlagWatchers {
materials[i] = Material.values()[i].name(); materials[i] = Material.values()[i].name();
} }
new ParamInfo(ItemStack.class, "Item (id:damage)", "An ItemStack compromised of ID:Durability", materials); new ParamInfo(ItemStack.class, "Item (id:damage), damage optional", "An ItemStack compromised of " +
"ID:Durability", materials);
new ParamInfo(ItemStack[].class, "Four ItemStacks (id:damage,id:damage..)", "Four ItemStacks separated by an ,", new ParamInfo(ItemStack[].class, "Four ItemStacks (id:damage,id:damage..), damage optional", "Four ItemStacks separated by an ,",
materials) { materials) {
@Override @Override
public String[] getEnums(String tabComplete) { public String[] getEnums(String tabComplete) {
@ -205,8 +207,8 @@ public class ReflectionFlagWatchers {
new ParamInfo(String.class, "Text", "A line of text"); new ParamInfo(String.class, "Text", "A line of text");
new ParamInfo(boolean.class, "True/False", "True or False", new String[]{"true", "false"}); new ParamInfo(boolean.class, "True/False", "True or False", new String[]{"true", "false"});
new ParamInfo(int.class, "Number", "A whole number, no decimals"); new ParamInfo(int.class, "Number", "A whole number, no decimals");
new ParamInfo(double.class, "Number", "A number which can have decimals"); new ParamInfo(double.class, "Number.0", "A number which can have decimals");
new ParamInfo(float.class, "Number", "A number which can have decimals"); new ParamInfo(float.class, "Number.0", "A number which can have decimals");
new ParamInfo(Horse.Style.class, "Horse Style", "Horse style which is the patterns on the horse"); new ParamInfo(Horse.Style.class, "Horse Style", "Horse style which is the patterns on the horse");
new ParamInfo(int[].class, "number,number,number..", "Numbers separated by an ,"); new ParamInfo(int[].class, "number,number,number..", "Numbers separated by an ,");

View File

@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities;
import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -57,6 +58,18 @@ public class TranslateFiller {
} }
} }
TranslateType.DISGUISE_OPTIONS.save("baby", "Used as a shortcut for setBaby when disguising an entity");
TranslateType.DISGUISE_OPTIONS.save("adult", "Used as a shortcut for setBaby(false) when disguising an entity");
for (Class c : ClassGetter.getClassesForPackage("org.bukkit.entity")) {
if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) {
TranslateType.DISGUISES.save(c.getSimpleName(),
"Name for the " + c.getSimpleName() + " EntityType, " + "this is used in radius commands");
}
}
TranslateType.DISGUISES.save("EntityType", "Used for the disgiuse radius command to list all entitytypes");
for (LibsMsg msg : LibsMsg.values()) { for (LibsMsg msg : LibsMsg.values()) {
TranslateType.MESSAGES.save(msg.getRaw()); TranslateType.MESSAGES.save(msg.getRaw());
} }

View File

@ -61,7 +61,7 @@ public enum TranslateType {
if (value == null) if (value == null)
System.err.println("Translation for " + name() + " has a null value for the key '" + key + "'"); System.err.println("Translation for " + name() + " has a null value for the key '" + key + "'");
else else if (!Objects.equals(key, value)) // Don't store useless information
translated.put(ChatColor.translateAlternateColorCodes('&', key), translated.put(ChatColor.translateAlternateColorCodes('&', key),
ChatColor.translateAlternateColorCodes('&', value)); ChatColor.translateAlternateColorCodes('&', value));
} }
@ -89,8 +89,6 @@ public enum TranslateType {
translated.put(message, message); translated.put(message, message);
message = StringEscapeUtils.escapeJava(message.replaceAll(ChatColor.COLOR_CHAR + "", "&")); message = StringEscapeUtils.escapeJava(message.replaceAll(ChatColor.COLOR_CHAR + "", "&"));
// String message1 = StringEscapeUtils.escapeJava(
// StringUtils.reverse(message).replaceAll("s%", "%s").replaceAll(ChatColor.COLOR_CHAR + "", "&"));
try { try {
boolean exists = file.exists(); boolean exists = file.exists();