commit
0546566686
9
.idea/codeStyleSettings.xml
Normal file
9
.idea/codeStyleSettings.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value />
|
||||
</option>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="My Style" />
|
||||
</component>
|
||||
</project>
|
@ -44,11 +44,9 @@ public class DisguiseAPI {
|
||||
|
||||
if (disguiseType.isMisc()) {
|
||||
disguise = new MiscDisguise(disguiseType);
|
||||
}
|
||||
else if (disguiseType.isMob()) {
|
||||
} else if (disguiseType.isMob()) {
|
||||
disguise = new MobDisguise(disguiseType);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
disguise = new PlayerDisguise(entity.getName());
|
||||
}
|
||||
|
||||
@ -60,8 +58,7 @@ public class DisguiseAPI {
|
||||
|
||||
if (effect.getType() == PotionEffectType.INVISIBILITY) {
|
||||
watcher.setInvisible(true);
|
||||
}
|
||||
else if (effect.getType() == PotionEffectType.GLOWING) {
|
||||
} else if (effect.getType() == PotionEffectType.GLOWING) {
|
||||
watcher.setGlowing(true);
|
||||
}
|
||||
}
|
||||
@ -91,8 +88,9 @@ public class DisguiseAPI {
|
||||
}
|
||||
}
|
||||
for (Method method : entity.getClass().getMethods()) {
|
||||
if ((doSneak || !method.getName().equals("setSneaking")) && (doSprint || !method.getName().equals("setSprinting"))
|
||||
&& method.getParameterTypes().length == 0 && method.getReturnType() != void.class) {
|
||||
if ((doSneak || !method.getName().equals("setSneaking")) && (doSprint || !method.getName()
|
||||
.equals("setSprinting")) && method.getParameterTypes().length == 0 && method
|
||||
.getReturnType() != void.class) {
|
||||
Class methodReturn = method.getReturnType();
|
||||
|
||||
if (methodReturn == float.class || methodReturn == Float.class || methodReturn == Double.class) {
|
||||
@ -103,8 +101,8 @@ public class DisguiseAPI {
|
||||
|
||||
if (firstCapitalMethod > 0) {
|
||||
for (Method watcherMethod : watcher.getClass().getMethods()) {
|
||||
if (!watcherMethod.getName().startsWith("get") && watcherMethod.getReturnType() == void.class
|
||||
&& watcherMethod.getParameterTypes().length == 1) {
|
||||
if (!watcherMethod.getName().startsWith("get") && watcherMethod
|
||||
.getReturnType() == void.class && watcherMethod.getParameterTypes().length == 1) {
|
||||
int firstCapitalWatcher = firstCapital(watcherMethod.getName());
|
||||
|
||||
if (firstCapitalWatcher > 0 && method.getName().substring(firstCapitalMethod)
|
||||
@ -113,8 +111,7 @@ public class DisguiseAPI {
|
||||
|
||||
if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) {
|
||||
methodParam = double.class;
|
||||
}
|
||||
else if (methodParam == AnimalColor.class) {
|
||||
} else if (methodParam == AnimalColor.class) {
|
||||
methodParam = DyeColor.class;
|
||||
}
|
||||
if (methodReturn == methodParam) {
|
||||
@ -128,19 +125,17 @@ public class DisguiseAPI {
|
||||
double d = (Double) value;
|
||||
value = (float) d;
|
||||
}
|
||||
}
|
||||
else if (toCast == double.class) {
|
||||
} else if (toCast == double.class) {
|
||||
if (!(value instanceof Double)) {
|
||||
float d = (Float) value;
|
||||
value = (double) d;
|
||||
}
|
||||
}
|
||||
else if (toCast == AnimalColor.class) {
|
||||
} else if (toCast == AnimalColor.class) {
|
||||
value = AnimalColor.valueOf(((DyeColor) value).name());
|
||||
}
|
||||
}
|
||||
if (value instanceof Boolean && !(Boolean) value
|
||||
&& watcherMethod.getDeclaringClass() == FlagWatcher.class) {
|
||||
if (value instanceof Boolean && !(Boolean) value && watcherMethod
|
||||
.getDeclaringClass() == FlagWatcher.class) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -195,8 +190,7 @@ public class DisguiseAPI {
|
||||
for (Object obj : playersToNotSeeDisguise) {
|
||||
if (obj instanceof String) {
|
||||
((TargetedDisguise) disguise).addPlayer((String) obj);
|
||||
}
|
||||
else if (obj instanceof Player) {
|
||||
} else if (obj instanceof Player) {
|
||||
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
||||
}
|
||||
}
|
||||
@ -275,8 +269,7 @@ public class DisguiseAPI {
|
||||
for (Object obj : playersToViewDisguise) {
|
||||
if (obj instanceof String) {
|
||||
((TargetedDisguise) disguise).addPlayer((String) obj);
|
||||
}
|
||||
else if (obj instanceof Player) {
|
||||
} else if (obj instanceof Player) {
|
||||
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
||||
}
|
||||
}
|
||||
@ -390,8 +383,8 @@ public class DisguiseAPI {
|
||||
* @return
|
||||
*/
|
||||
public static boolean isViewSelfToggled(Entity entity) {
|
||||
return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible()
|
||||
: Disguise.getViewSelf().contains(entity.getUniqueId());
|
||||
return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible() :
|
||||
Disguise.getViewSelf().contains(entity.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -416,16 +409,18 @@ public class DisguiseAPI {
|
||||
*/
|
||||
public static void setViewDisguiseToggled(Entity entity, boolean toggled) {
|
||||
if (isDisguised(entity)) {
|
||||
Disguise disguise = getDisguise(entity);
|
||||
Disguise[] disguises = getDisguises(entity);
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.setViewSelfDisguise(toggled);
|
||||
}
|
||||
}
|
||||
|
||||
if (toggled) {
|
||||
if (!Disguise.getViewSelf().contains(entity.getUniqueId())) {
|
||||
Disguise.getViewSelf().add(entity.getUniqueId());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Disguise.getViewSelf().remove(entity.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -78,8 +78,6 @@ public class LibsDisguises extends JavaPlugin {
|
||||
|
||||
PacketsManager.addPacketListeners();
|
||||
|
||||
TranslateType.MESSAGES.name(); // Call the static loader
|
||||
|
||||
listener = new DisguiseListener(this);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(listener, this);
|
||||
@ -322,30 +320,30 @@ public class LibsDisguises extends JavaPlugin {
|
||||
MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex());
|
||||
|
||||
if (flagType == null) {
|
||||
System.err.println(
|
||||
"Error finding the FlagType for " + disguiseType.name() + "! Index " + watch.getIndex() + " can't be found!");
|
||||
System.err.println(
|
||||
"Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName());
|
||||
System.err.println("Error finding the FlagType for " + disguiseType.name() + "! Index " + watch
|
||||
.getIndex() + " can't be found!");
|
||||
System.err.println("Value is " + watch.getRawValue() + " (" + watch.getRawValue()
|
||||
.getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName());
|
||||
System.err.println("Lib's Disguises will continue to load, but this will not work properly!");
|
||||
continue;
|
||||
}
|
||||
|
||||
indexes.remove(flagType);
|
||||
|
||||
if (ReflectionManager.convertInvalidItem(
|
||||
flagType.getDefault()).getClass() != ReflectionManager.convertInvalidItem(
|
||||
watch.getValue()).getClass()) {
|
||||
System.err.println(
|
||||
"Mismatch of FlagType's for " + disguiseType.name() + "! Index " + watch.getIndex() + " has the wrong classtype!");
|
||||
System.err.println(
|
||||
"Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName() + " which doesn't match up with " + flagType.getDefault().getClass());
|
||||
if (ReflectionManager.convertInvalidItem(flagType.getDefault()).getClass() != ReflectionManager
|
||||
.convertInvalidItem(watch.getValue()).getClass()) {
|
||||
System.err.println("Mismatch of FlagType's for " + disguiseType.name() + "! Index " + watch
|
||||
.getIndex() + " has the wrong classtype!");
|
||||
System.err.println("Value is " + watch.getRawValue() + " (" + watch.getRawValue()
|
||||
.getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass
|
||||
.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!");
|
||||
}
|
||||
}
|
||||
|
||||
for (MetaIndex index : indexes) {
|
||||
System.out.println(
|
||||
disguiseType + " has MetaIndex remaining! " + index.getFlagWatcher().getSimpleName() + " at index " + index.getIndex());
|
||||
System.out.println(disguiseType + " has MetaIndex remaining! " + index.getFlagWatcher()
|
||||
.getSimpleName() + " at index " + index.getIndex());
|
||||
}
|
||||
|
||||
DisguiseSound sound = DisguiseSound.getType(disguiseType.name());
|
||||
@ -374,12 +372,12 @@ public class LibsDisguises extends JavaPlugin {
|
||||
disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity));
|
||||
}
|
||||
catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex) {
|
||||
System.out.print(
|
||||
"[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType.name() + "!");
|
||||
System.out.print(
|
||||
"[LibsDisguises] Before reporting this error, " + "please make sure you are using the latest version of LibsDisguises and ProtocolLib.");
|
||||
System.out.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+/");
|
||||
System.out.print("[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType
|
||||
.name() + "!");
|
||||
System.out
|
||||
.print("[LibsDisguises] Before reporting this error, " + "please make sure you are using the latest version of LibsDisguises and ProtocolLib.");
|
||||
System.out
|
||||
.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();
|
||||
}
|
||||
|
@ -38,15 +38,14 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
||||
|
||||
for (int i = player == null ? 0 : 1; i < args.length; i++) {
|
||||
String option = args[i];
|
||||
if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip") || StringUtils
|
||||
.startsWithIgnoreCase(option, "ignoreEnquip")) {
|
||||
if (StringUtils.startsWithIgnoreCase(option, LibsMsg.DCLONE_EQUIP.get())) {
|
||||
doEquipment = false;
|
||||
} else if (option.equalsIgnoreCase("doSneakSprint")) {
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAKSPRINT.get())) {
|
||||
doSneak = true;
|
||||
doSprint = true;
|
||||
} else if (option.equalsIgnoreCase("doSneak")) {
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAK.get())) {
|
||||
doSneak = true;
|
||||
} else if (option.equalsIgnoreCase("doSprint")) {
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SPRINT.get())) {
|
||||
doSprint = true;
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.INVALID_CLONE.get(option));
|
||||
@ -82,10 +81,10 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
||||
}
|
||||
}
|
||||
|
||||
tabs.add("ignoreEquip");
|
||||
tabs.add("doSneakSprint");
|
||||
tabs.add("doSneak");
|
||||
tabs.add("doSprint");
|
||||
tabs.add(LibsMsg.DCLONE_EQUIP.get());
|
||||
tabs.add(LibsMsg.DCLONE_SNEAKSPRINT.get());
|
||||
tabs.add(LibsMsg.DCLONE_SNEAK.get());
|
||||
tabs.add(LibsMsg.DCLONE_SPRINT.get());
|
||||
|
||||
return filterTabs(tabs, origArgs);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
|
||||
try {
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(watcher)) {
|
||||
if (args.length < 2 || !args[1].equalsIgnoreCase("show")) {
|
||||
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
|
||||
boolean allowed = false;
|
||||
|
||||
for (ArrayList<String> key : permMap.get(type).keySet()) {
|
||||
@ -112,7 +112,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
methodColor = ChatColor.GRAY;
|
||||
}
|
||||
|
||||
String str = method.getName() + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info
|
||||
String str = TranslateType.DISGUISE_OPTIONS
|
||||
.get(method.getName()) + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info
|
||||
.getName() + ChatColor.DARK_RED + ")";
|
||||
|
||||
map.put(str, methodColor);
|
||||
@ -130,7 +131,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
}
|
||||
|
||||
if (methods.isEmpty()) {
|
||||
methods.add(ChatColor.RED + "No options with permission to use");
|
||||
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.DHELP_OPTIONS.get(ChatColor.DARK_RED + type.toReadable(),
|
||||
@ -170,7 +171,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
tabs.add(s.getName().replaceAll(" ", ""));
|
||||
}
|
||||
} else if (DisguiseParser.getDisguisePerm(args[0]) == null) {
|
||||
tabs.add("Show");
|
||||
tabs.add(LibsMsg.DHELP_SHOW.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,11 +57,12 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
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<>();
|
||||
|
||||
for (Class c : validClasses) {
|
||||
classes.add(c.getSimpleName());
|
||||
classes.add(TranslateType.DISGUISES.get(c.getSimpleName()));
|
||||
}
|
||||
|
||||
Collections.sort(classes);
|
||||
@ -77,7 +78,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
if (!isNumeric(args[0])) {
|
||||
for (Class c : validClasses) {
|
||||
if (c.getSimpleName().equalsIgnoreCase(args[0])) {
|
||||
if (TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0])) {
|
||||
entityClass = c;
|
||||
starting = 1;
|
||||
break;
|
||||
@ -208,7 +209,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
if (args.length == 0) {
|
||||
for (Class<? extends Entity> entityClass : validClasses) {
|
||||
tabs.add(entityClass.getSimpleName());
|
||||
tabs.add(TranslateType.DISGUISES.get(entityClass.getSimpleName()));
|
||||
}
|
||||
|
||||
return filterTabs(tabs, origArgs);
|
||||
@ -218,7 +219,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
if (!isNumeric(args[0])) {
|
||||
for (Class c : validClasses) {
|
||||
if (!c.getSimpleName().equalsIgnoreCase(args[0]))
|
||||
if (!TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0]))
|
||||
continue;
|
||||
|
||||
starting = 2;
|
||||
|
@ -322,6 +322,6 @@ public enum DisguiseType {
|
||||
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
return TranslateType.DISGUISES.get(StringUtils.join(split, " "), "Name for the " + name() + " disguise");
|
||||
return TranslateType.DISGUISES.get(StringUtils.join(split, " "));
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
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.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
public class DisguiseParser {
|
||||
public static class DisguiseParseException extends Exception {
|
||||
@ -86,10 +88,6 @@ public class DisguiseParser {
|
||||
return getType().isUnknown();
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return permName == null ? getType().name() : permName;
|
||||
}
|
||||
|
||||
public String toReadable() {
|
||||
return permName == null ? getType().toReadable() : permName;
|
||||
}
|
||||
@ -129,14 +127,14 @@ public class DisguiseParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static Object callValueOf(Class<?> param, String valueString, String methodName,
|
||||
String description) throws DisguiseParseException {
|
||||
private static Object callValueOf(Class<?> param, String valueString,
|
||||
String methodName) throws DisguiseParseException {
|
||||
Object value;
|
||||
try {
|
||||
value = param.getMethod("valueOf", String.class).invoke(null, valueString.toUpperCase());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException(description, valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -169,7 +167,7 @@ public class DisguiseParser {
|
||||
String[] split = lowerPerm.substring(beginning.length()).split("\\.");
|
||||
|
||||
if (split.length > 1) {
|
||||
if (split[0].replace("_", "").equals(type.name().toLowerCase().replace("_", ""))) {
|
||||
if (split[0].replace("_", "").equals(type.toReadable().toLowerCase().replace(" ", ""))) {
|
||||
for (int i = 1; i < split.length; i++) {
|
||||
returns.put(split[i], permission.getValue());
|
||||
}
|
||||
@ -186,14 +184,14 @@ public class DisguiseParser {
|
||||
|
||||
public static DisguisePerm getDisguisePerm(String name) {
|
||||
for (DisguisePerm perm : getDisguisePerms()) {
|
||||
if (!perm.name().equalsIgnoreCase(name) && !perm.name().replace("_", "").equalsIgnoreCase(name))
|
||||
if (!perm.toReadable().equalsIgnoreCase(name) && !perm.toReadable().replace(" ", "").equalsIgnoreCase(name))
|
||||
continue;
|
||||
|
||||
return perm;
|
||||
}
|
||||
|
||||
if (name.equalsIgnoreCase("p"))
|
||||
return getDisguisePerm("player");
|
||||
return getDisguisePerm(DisguiseType.PLAYER.toReadable());
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -534,10 +532,11 @@ public class DisguiseParser {
|
||||
boolean adult = true;
|
||||
|
||||
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");
|
||||
doCheck(sender, optionPermissions, usedOptions);
|
||||
adult = args[1].equalsIgnoreCase("adult");
|
||||
adult = args[1].equalsIgnoreCase(TranslateType.DISGUISE_OPTIONS.get("adult"));
|
||||
|
||||
toSkip++;
|
||||
}
|
||||
@ -664,7 +663,8 @@ public class DisguiseParser {
|
||||
Method[] methods = ReflectionFlagWatchers.getDisguiseWatcherMethods(disguise.getWatcher().getClass());
|
||||
|
||||
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
|
||||
.reverseGet(args.length - 1 == i ? null : args[i + 1]);
|
||||
Method methodToUse = null;
|
||||
@ -682,7 +682,7 @@ public class DisguiseParser {
|
||||
|
||||
methodToUse = entry.getKey();
|
||||
c = entry.getValue();
|
||||
methodName = methodToUse.getName();
|
||||
methodName = TranslateType.DISGUISE_OPTIONS.reverseGet(methodNameRaw = methodToUse.getName());
|
||||
Class<?>[] types = methodToUse.getParameterTypes();
|
||||
Class param = types[0];
|
||||
|
||||
@ -692,14 +692,14 @@ public class DisguiseParser {
|
||||
if (isInteger(valueString)) {
|
||||
value = Integer.parseInt(valueString);
|
||||
} else {
|
||||
throw parseToException("number", valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
} else if (WrappedGameProfile.class == param && valueString.length() > 20) {
|
||||
try {
|
||||
value = ReflectionManager.parseGameProfile(valueString);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException("gameprofile", valueString, methodName);
|
||||
throw parseToException(GameProfile.class, valueString, methodName);
|
||||
}
|
||||
} else if (float.class == param || double.class == param) {
|
||||
// Parse to number
|
||||
@ -711,10 +711,10 @@ public class DisguiseParser {
|
||||
value = (double) obj;
|
||||
}
|
||||
} else {
|
||||
throw parseToException("number.0", valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
} else if (param == String.class) {
|
||||
if (methodName.equalsIgnoreCase("setskin") && valueString.length() > 20) {
|
||||
if (methodNameRaw.equalsIgnoreCase("setskin") && valueString.length() > 20) {
|
||||
value = valueString;
|
||||
} else {
|
||||
// Parse to string
|
||||
@ -726,18 +726,18 @@ public class DisguiseParser {
|
||||
value = AnimalColor.valueOf(valueString.toUpperCase());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException("animal color", valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
} else if (param == Llama.Color.class) {
|
||||
try {
|
||||
value = Llama.Color.valueOf(valueString.toUpperCase());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException("llama color", valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
} else if (param == ItemStack.class) {
|
||||
// Parse to itemstack
|
||||
value = parseToItemstack(methodName, valueString);
|
||||
value = parseToItemstack(param, methodName, valueString);
|
||||
} else if (param == ItemStack[].class) {
|
||||
// Parse to itemstack array
|
||||
ItemStack[] items = new ItemStack[4];
|
||||
@ -747,39 +747,35 @@ public class DisguiseParser {
|
||||
if (split.length == 4) {
|
||||
for (int a = 0; a < 4; a++) {
|
||||
try {
|
||||
items[a] = parseToItemstack(methodName, split[a]);
|
||||
items[a] = parseToItemstack(param, methodName, split[a]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException(
|
||||
"item ID,ID,ID,ID" + ChatColor.RED + " or " + ChatColor.GREEN + "ID:Data,ID:Data,ID:Data,ID:Data combo",
|
||||
valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw parseToException(
|
||||
"item ID,ID,ID,ID" + ChatColor.RED + " or " + ChatColor.GREEN + "ID:Data,ID:Data,ID:Data,ID:Data combo",
|
||||
valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
|
||||
value = items;
|
||||
} else if (param.getSimpleName().equals("Color")) {
|
||||
// Parse to horse color
|
||||
value = callValueOf(param, valueString, methodName, "a horse color");
|
||||
value = callValueOf(param, valueString, methodName);
|
||||
} else if (param.getSimpleName().equals("Style")) {
|
||||
// Parse to horse style
|
||||
value = callValueOf(param, valueString, methodName, "a horse style");
|
||||
value = callValueOf(param, valueString, methodName);
|
||||
} else if (param.getSimpleName().equals("Profession")) {
|
||||
// Parse to villager profession
|
||||
value = callValueOf(param, valueString, methodName, "a villager profession");
|
||||
value = callValueOf(param, valueString, methodName);
|
||||
} else if (param.getSimpleName().equals("Art")) {
|
||||
// Parse to art type
|
||||
value = callValueOf(param, valueString, methodName, "a painting art");
|
||||
value = callValueOf(param, valueString, methodName);
|
||||
} else if (param.getSimpleName().equals("Type")) {
|
||||
// Parse to ocelot type
|
||||
value = callValueOf(param, valueString, methodName, "a ocelot type");
|
||||
value = callValueOf(param, valueString, methodName);
|
||||
} else if (param.getSimpleName().equals("TreeSpecies")) {
|
||||
// Parse to ocelot type
|
||||
value = callValueOf(param, valueString, methodName, "a tree species");
|
||||
value = callValueOf(param, valueString, methodName);
|
||||
} else if (param == PotionEffectType.class) {
|
||||
// Parse to potion effect
|
||||
try {
|
||||
@ -796,7 +792,7 @@ public class DisguiseParser {
|
||||
value = potionType;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException("a potioneffect type", valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
} else if (param == int[].class) {
|
||||
String[] split = valueString.split(",");
|
||||
@ -808,7 +804,7 @@ public class DisguiseParser {
|
||||
values[b] = Integer.parseInt(split[b]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
throw parseToException("Number,Number,Number...", valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -824,8 +820,7 @@ public class DisguiseParser {
|
||||
value = face;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException("a direction (north, east, south, west, up, down)", valueString,
|
||||
methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
} else if (param == RabbitType.class) {
|
||||
try {
|
||||
@ -842,8 +837,7 @@ public class DisguiseParser {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException("rabbit type (white, brown, patches...)", valueString,
|
||||
methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
}
|
||||
} else if (param == BlockPosition.class) {
|
||||
try {
|
||||
@ -855,10 +849,10 @@ public class DisguiseParser {
|
||||
Integer.parseInt(split[2]));
|
||||
}
|
||||
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")) {
|
||||
value = callValueOf(param, valueString, methodName, "a parrot color");
|
||||
value = callValueOf(param, valueString, methodName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -866,13 +860,15 @@ public class DisguiseParser {
|
||||
if (valueString == null) {
|
||||
value = true;
|
||||
i--;
|
||||
} else if (valueString.equalsIgnoreCase("true")) {
|
||||
} else if (valueString
|
||||
.equalsIgnoreCase(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("true"))) {
|
||||
value = true;
|
||||
} else if (valueString.equalsIgnoreCase("false")) {
|
||||
} else if (valueString
|
||||
.equalsIgnoreCase(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("false"))) {
|
||||
value = false;
|
||||
} else {
|
||||
if (getMethod(methods, valueString, 0) == null) {
|
||||
throw parseToException("true/false", valueString, methodName);
|
||||
throw parseToException(param, valueString, methodName);
|
||||
} else {
|
||||
value = true;
|
||||
i--;
|
||||
@ -905,8 +901,8 @@ public class DisguiseParser {
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_NO_OPTION_VALUE, methodName);
|
||||
}
|
||||
|
||||
if (!usedOptions.contains(methodName.toLowerCase())) {
|
||||
usedOptions.add(methodName.toLowerCase());
|
||||
if (!usedOptions.contains(methodNameRaw.toLowerCase())) {
|
||||
usedOptions.add(methodNameRaw.toLowerCase());
|
||||
}
|
||||
|
||||
doCheck(sender, optionPermissions, usedOptions);
|
||||
@ -919,12 +915,12 @@ public class DisguiseParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static DisguiseParseException parseToException(String expectedValue, String receivedInstead,
|
||||
String methodName) {
|
||||
return new DisguiseParseException(LibsMsg.PARSE_EXPECTED_RECEIVED, expectedValue, receivedInstead, methodName);
|
||||
private static DisguiseParseException parseToException(Class paramType, String receivedInstead, String methodName) {
|
||||
return new DisguiseParseException(LibsMsg.PARSE_EXPECTED_RECEIVED,
|
||||
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);
|
||||
|
||||
int itemId = -1;
|
||||
@ -946,16 +942,16 @@ public class DisguiseParser {
|
||||
if (isInteger(split[1])) {
|
||||
itemDura = Short.parseShort(split[1]);
|
||||
} else {
|
||||
throw parseToException("item ID:Durability combo", string, "%s");
|
||||
throw parseToException(param, string, "%s");
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemStack(itemId, 1, itemDura);
|
||||
} else {
|
||||
if (split.length == 1) {
|
||||
throw parseToException("item ID", string, "%s");
|
||||
throw parseToException(param, string, "%s");
|
||||
} else {
|
||||
throw parseToException("item ID:Durability combo", string, "%s");
|
||||
throw parseToException(param, string, "%s");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,12 @@ public enum LibsMsg {
|
||||
DMODPLAYER_NOPERM(ChatColor.RED + "You do not have permission to modify this disguise"),
|
||||
DMODRADIUS(ChatColor.RED + "Successfully modified the disguises of %s entities!"),
|
||||
DMODRADIUS_HELP1(ChatColor.DARK_GREEN + "Modify the disguises in a radius! Caps at %s blocks!"),
|
||||
DHELP_SHOW("Show"),
|
||||
DHELP_NO_OPTIONS(ChatColor.RED + "No options with permission to use"),
|
||||
DCLONE_EQUIP("ignoreEquip"),
|
||||
DCLONE_SNEAKSPRINT("doSneakSprint"),
|
||||
DCLONE_SNEAK("doSneak"),
|
||||
DCLONE_SPRINT("doSprint"),
|
||||
DMODRADIUS_HELP3(
|
||||
(ChatColor.DARK_GREEN + "/disguisemodifyradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")> <Radius> player <Name>")
|
||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
||||
|
@ -81,8 +81,7 @@ public class ReflectionFlagWatchers {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
||||
.get(getRawName(), "Used as a disguise option for " + getRawName());
|
||||
return TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(getRawName());
|
||||
}
|
||||
|
||||
public String getRawName() {
|
||||
@ -90,8 +89,7 @@ public class ReflectionFlagWatchers {
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
||||
.get(getRawDescription(), "Used as a disguise option for " + getRawDescription());
|
||||
return TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(getRawDescription());
|
||||
}
|
||||
|
||||
public String getRawDescription() {
|
||||
@ -152,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(Villager.Profession.class, "Villager Profession",
|
||||
"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");
|
||||
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");
|
||||
@ -179,9 +178,10 @@ public class ReflectionFlagWatchers {
|
||||
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) {
|
||||
@Override
|
||||
public String[] getEnums(String tabComplete) {
|
||||
@ -207,8 +207,8 @@ public class ReflectionFlagWatchers {
|
||||
new ParamInfo(String.class, "Text", "A line of text");
|
||||
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(double.class, "Number", "A number which can have decimals");
|
||||
new ParamInfo(float.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.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(int[].class, "number,number,number..", "Numbers separated by an ,");
|
||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@ -15,16 +16,13 @@ public class TranslateFiller {
|
||||
// Fill the configs
|
||||
|
||||
for (ReflectionFlagWatchers.ParamInfo info : ReflectionFlagWatchers.getParamInfos()) {
|
||||
if (!info.isEnums())
|
||||
continue;
|
||||
|
||||
if (info.getParamClass() == ItemStack.class || info.getParamClass() == ItemStack[].class)
|
||||
continue;
|
||||
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.save(info.getRawName(), "Used as a disguise option");
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
||||
.save(info.getRawDescription(), "Description for the disguise option " + info.getRawName());
|
||||
|
||||
if (!info.isEnums() || info.getParamClass() == ItemStack.class || info.getParamClass() == ItemStack[].class)
|
||||
continue;
|
||||
|
||||
for (String e : info.getEnums("")) {
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.save(e, "Used for the disguise option " + info.getRawName());
|
||||
}
|
||||
@ -60,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()) {
|
||||
TranslateType.MESSAGES.save(msg.getRaw());
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.libraryaddict.disguise.utilities;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@ -60,7 +61,7 @@ public enum TranslateType {
|
||||
|
||||
if (value == null)
|
||||
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),
|
||||
ChatColor.translateAlternateColorCodes('&', value));
|
||||
}
|
||||
@ -134,23 +135,11 @@ public enum TranslateType {
|
||||
}
|
||||
|
||||
public String get(String msg) {
|
||||
if (this != TranslateType.MESSAGES)
|
||||
throw new IllegalArgumentException("Can't set no comment for '" + msg + "'");
|
||||
|
||||
return get(msg, null);
|
||||
}
|
||||
|
||||
public String get(String msg, String comment) {
|
||||
if (msg == null || !LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations())
|
||||
return msg;
|
||||
|
||||
String toReturn = translated.get(msg);
|
||||
|
||||
if (toReturn != null)
|
||||
return toReturn;
|
||||
|
||||
save(msg, comment);
|
||||
|
||||
return msg;
|
||||
return toReturn == null ? msg : toReturn;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user