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()) {
|
if (disguiseType.isMisc()) {
|
||||||
disguise = new MiscDisguise(disguiseType);
|
disguise = new MiscDisguise(disguiseType);
|
||||||
}
|
} else if (disguiseType.isMob()) {
|
||||||
else if (disguiseType.isMob()) {
|
|
||||||
disguise = new MobDisguise(disguiseType);
|
disguise = new MobDisguise(disguiseType);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
disguise = new PlayerDisguise(entity.getName());
|
disguise = new PlayerDisguise(entity.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +58,7 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
if (effect.getType() == PotionEffectType.INVISIBILITY) {
|
if (effect.getType() == PotionEffectType.INVISIBILITY) {
|
||||||
watcher.setInvisible(true);
|
watcher.setInvisible(true);
|
||||||
}
|
} else if (effect.getType() == PotionEffectType.GLOWING) {
|
||||||
else if (effect.getType() == PotionEffectType.GLOWING) {
|
|
||||||
watcher.setGlowing(true);
|
watcher.setGlowing(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,8 +88,9 @@ public class DisguiseAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Method method : entity.getClass().getMethods()) {
|
for (Method method : entity.getClass().getMethods()) {
|
||||||
if ((doSneak || !method.getName().equals("setSneaking")) && (doSprint || !method.getName().equals("setSprinting"))
|
if ((doSneak || !method.getName().equals("setSneaking")) && (doSprint || !method.getName()
|
||||||
&& method.getParameterTypes().length == 0 && method.getReturnType() != void.class) {
|
.equals("setSprinting")) && method.getParameterTypes().length == 0 && method
|
||||||
|
.getReturnType() != void.class) {
|
||||||
Class methodReturn = method.getReturnType();
|
Class methodReturn = method.getReturnType();
|
||||||
|
|
||||||
if (methodReturn == float.class || methodReturn == Float.class || methodReturn == Double.class) {
|
if (methodReturn == float.class || methodReturn == Float.class || methodReturn == Double.class) {
|
||||||
@ -103,8 +101,8 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
if (firstCapitalMethod > 0) {
|
if (firstCapitalMethod > 0) {
|
||||||
for (Method watcherMethod : watcher.getClass().getMethods()) {
|
for (Method watcherMethod : watcher.getClass().getMethods()) {
|
||||||
if (!watcherMethod.getName().startsWith("get") && watcherMethod.getReturnType() == void.class
|
if (!watcherMethod.getName().startsWith("get") && watcherMethod
|
||||||
&& watcherMethod.getParameterTypes().length == 1) {
|
.getReturnType() == void.class && watcherMethod.getParameterTypes().length == 1) {
|
||||||
int firstCapitalWatcher = firstCapital(watcherMethod.getName());
|
int firstCapitalWatcher = firstCapital(watcherMethod.getName());
|
||||||
|
|
||||||
if (firstCapitalWatcher > 0 && method.getName().substring(firstCapitalMethod)
|
if (firstCapitalWatcher > 0 && method.getName().substring(firstCapitalMethod)
|
||||||
@ -113,8 +111,7 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) {
|
if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) {
|
||||||
methodParam = double.class;
|
methodParam = double.class;
|
||||||
}
|
} else if (methodParam == AnimalColor.class) {
|
||||||
else if (methodParam == AnimalColor.class) {
|
|
||||||
methodParam = DyeColor.class;
|
methodParam = DyeColor.class;
|
||||||
}
|
}
|
||||||
if (methodReturn == methodParam) {
|
if (methodReturn == methodParam) {
|
||||||
@ -128,19 +125,17 @@ public class DisguiseAPI {
|
|||||||
double d = (Double) value;
|
double d = (Double) value;
|
||||||
value = (float) d;
|
value = (float) d;
|
||||||
}
|
}
|
||||||
}
|
} else if (toCast == double.class) {
|
||||||
else if (toCast == double.class) {
|
|
||||||
if (!(value instanceof Double)) {
|
if (!(value instanceof Double)) {
|
||||||
float d = (Float) value;
|
float d = (Float) value;
|
||||||
value = (double) d;
|
value = (double) d;
|
||||||
}
|
}
|
||||||
}
|
} else if (toCast == AnimalColor.class) {
|
||||||
else if (toCast == AnimalColor.class) {
|
|
||||||
value = AnimalColor.valueOf(((DyeColor) value).name());
|
value = AnimalColor.valueOf(((DyeColor) value).name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (value instanceof Boolean && !(Boolean) value
|
if (value instanceof Boolean && !(Boolean) value && watcherMethod
|
||||||
&& watcherMethod.getDeclaringClass() == FlagWatcher.class) {
|
.getDeclaringClass() == FlagWatcher.class) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,8 +190,7 @@ public class DisguiseAPI {
|
|||||||
for (Object obj : playersToNotSeeDisguise) {
|
for (Object obj : playersToNotSeeDisguise) {
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
((TargetedDisguise) disguise).addPlayer((String) obj);
|
((TargetedDisguise) disguise).addPlayer((String) obj);
|
||||||
}
|
} else if (obj instanceof Player) {
|
||||||
else if (obj instanceof Player) {
|
|
||||||
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,8 +269,7 @@ public class DisguiseAPI {
|
|||||||
for (Object obj : playersToViewDisguise) {
|
for (Object obj : playersToViewDisguise) {
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
((TargetedDisguise) disguise).addPlayer((String) obj);
|
((TargetedDisguise) disguise).addPlayer((String) obj);
|
||||||
}
|
} else if (obj instanceof Player) {
|
||||||
else if (obj instanceof Player) {
|
|
||||||
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,8 +383,8 @@ public class DisguiseAPI {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isViewSelfToggled(Entity entity) {
|
public static boolean isViewSelfToggled(Entity entity) {
|
||||||
return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible()
|
return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible() :
|
||||||
: Disguise.getViewSelf().contains(entity.getUniqueId());
|
Disguise.getViewSelf().contains(entity.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -416,16 +409,18 @@ public class DisguiseAPI {
|
|||||||
*/
|
*/
|
||||||
public static void setViewDisguiseToggled(Entity entity, boolean toggled) {
|
public static void setViewDisguiseToggled(Entity entity, boolean toggled) {
|
||||||
if (isDisguised(entity)) {
|
if (isDisguised(entity)) {
|
||||||
Disguise disguise = getDisguise(entity);
|
Disguise[] disguises = getDisguises(entity);
|
||||||
|
|
||||||
|
for (Disguise disguise : disguises) {
|
||||||
disguise.setViewSelfDisguise(toggled);
|
disguise.setViewSelfDisguise(toggled);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (toggled) {
|
if (toggled) {
|
||||||
if (!Disguise.getViewSelf().contains(entity.getUniqueId())) {
|
if (!Disguise.getViewSelf().contains(entity.getUniqueId())) {
|
||||||
Disguise.getViewSelf().add(entity.getUniqueId());
|
Disguise.getViewSelf().add(entity.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Disguise.getViewSelf().remove(entity.getUniqueId());
|
Disguise.getViewSelf().remove(entity.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -38,15 +38,14 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
|||||||
|
|
||||||
for (int i = player == null ? 0 : 1; i < args.length; i++) {
|
for (int i = player == null ? 0 : 1; i < args.length; i++) {
|
||||||
String option = args[i];
|
String option = args[i];
|
||||||
if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip") || StringUtils
|
if (StringUtils.startsWithIgnoreCase(option, LibsMsg.DCLONE_EQUIP.get())) {
|
||||||
.startsWithIgnoreCase(option, "ignoreEnquip")) {
|
|
||||||
doEquipment = false;
|
doEquipment = false;
|
||||||
} else if (option.equalsIgnoreCase("doSneakSprint")) {
|
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAKSPRINT.get())) {
|
||||||
doSneak = true;
|
doSneak = true;
|
||||||
doSprint = true;
|
doSprint = true;
|
||||||
} else if (option.equalsIgnoreCase("doSneak")) {
|
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAK.get())) {
|
||||||
doSneak = true;
|
doSneak = true;
|
||||||
} else if (option.equalsIgnoreCase("doSprint")) {
|
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SPRINT.get())) {
|
||||||
doSprint = true;
|
doSprint = true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.INVALID_CLONE.get(option));
|
sender.sendMessage(LibsMsg.INVALID_CLONE.get(option));
|
||||||
@ -82,10 +81,10 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tabs.add("ignoreEquip");
|
tabs.add(LibsMsg.DCLONE_EQUIP.get());
|
||||||
tabs.add("doSneakSprint");
|
tabs.add(LibsMsg.DCLONE_SNEAKSPRINT.get());
|
||||||
tabs.add("doSneak");
|
tabs.add(LibsMsg.DCLONE_SNEAK.get());
|
||||||
tabs.add("doSprint");
|
tabs.add(LibsMsg.DCLONE_SPRINT.get());
|
||||||
|
|
||||||
return filterTabs(tabs, origArgs);
|
return filterTabs(tabs, origArgs);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(watcher)) {
|
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;
|
boolean allowed = false;
|
||||||
|
|
||||||
for (ArrayList<String> key : permMap.get(type).keySet()) {
|
for (ArrayList<String> key : permMap.get(type).keySet()) {
|
||||||
@ -112,7 +112,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
methodColor = ChatColor.GRAY;
|
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 + ")";
|
.getName() + ChatColor.DARK_RED + ")";
|
||||||
|
|
||||||
map.put(str, methodColor);
|
map.put(str, methodColor);
|
||||||
@ -130,7 +131,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (methods.isEmpty()) {
|
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(),
|
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(" ", ""));
|
tabs.add(s.getName().replaceAll(" ", ""));
|
||||||
}
|
}
|
||||||
} else if (DisguiseParser.getDisguisePerm(args[0]) == null) {
|
} 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;
|
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;
|
||||||
|
@ -322,6 +322,6 @@ public enum DisguiseType {
|
|||||||
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
|
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.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 {
|
||||||
@ -86,10 +88,6 @@ public class DisguiseParser {
|
|||||||
return getType().isUnknown();
|
return getType().isUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return permName == null ? getType().name() : permName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toReadable() {
|
public String toReadable() {
|
||||||
return permName == null ? getType().toReadable() : permName;
|
return permName == null ? getType().toReadable() : permName;
|
||||||
}
|
}
|
||||||
@ -129,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;
|
||||||
}
|
}
|
||||||
@ -169,7 +167,7 @@ public class DisguiseParser {
|
|||||||
String[] split = lowerPerm.substring(beginning.length()).split("\\.");
|
String[] split = lowerPerm.substring(beginning.length()).split("\\.");
|
||||||
|
|
||||||
if (split.length > 1) {
|
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++) {
|
for (int i = 1; i < split.length; i++) {
|
||||||
returns.put(split[i], permission.getValue());
|
returns.put(split[i], permission.getValue());
|
||||||
}
|
}
|
||||||
@ -186,14 +184,14 @@ public class DisguiseParser {
|
|||||||
|
|
||||||
public static DisguisePerm getDisguisePerm(String name) {
|
public static DisguisePerm getDisguisePerm(String name) {
|
||||||
for (DisguisePerm perm : getDisguisePerms()) {
|
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;
|
continue;
|
||||||
|
|
||||||
return perm;
|
return perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equalsIgnoreCase("p"))
|
if (name.equalsIgnoreCase("p"))
|
||||||
return getDisguisePerm("player");
|
return getDisguisePerm(DisguiseType.PLAYER.toReadable());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -534,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++;
|
||||||
}
|
}
|
||||||
@ -664,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;
|
||||||
@ -682,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];
|
||||||
|
|
||||||
@ -692,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
|
||||||
@ -711,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
|
||||||
@ -726,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];
|
||||||
@ -747,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 {
|
||||||
@ -796,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(",");
|
||||||
@ -808,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,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 {
|
||||||
@ -842,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 {
|
||||||
@ -855,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,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--;
|
||||||
@ -905,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);
|
||||||
@ -919,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;
|
||||||
@ -946,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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,12 @@ public enum LibsMsg {
|
|||||||
DMODPLAYER_NOPERM(ChatColor.RED + "You do not have permission to modify this disguise"),
|
DMODPLAYER_NOPERM(ChatColor.RED + "You do not have permission to modify this disguise"),
|
||||||
DMODRADIUS(ChatColor.RED + "Successfully modified the disguises of %s entities!"),
|
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!"),
|
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(
|
DMODRADIUS_HELP3(
|
||||||
(ChatColor.DARK_GREEN + "/disguisemodifyradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")> <Radius> player <Name>")
|
(ChatColor.DARK_GREEN + "/disguisemodifyradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")> <Radius> player <Name>")
|
||||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
||||||
|
@ -81,8 +81,7 @@ public class ReflectionFlagWatchers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
return TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(getRawName());
|
||||||
.get(getRawName(), "Used as a disguise option for " + getRawName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRawName() {
|
public String getRawName() {
|
||||||
@ -90,8 +89,7 @@ public class ReflectionFlagWatchers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
return TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(getRawDescription());
|
||||||
.get(getRawDescription(), "Used as a disguise option for " + getRawDescription());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String 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(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");
|
||||||
@ -179,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) {
|
||||||
@ -207,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 ,");
|
||||||
|
@ -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;
|
||||||
@ -15,16 +16,13 @@ public class TranslateFiller {
|
|||||||
// Fill the configs
|
// Fill the configs
|
||||||
|
|
||||||
for (ReflectionFlagWatchers.ParamInfo info : ReflectionFlagWatchers.getParamInfos()) {
|
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.getRawName(), "Used as a disguise option");
|
||||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
||||||
.save(info.getRawDescription(), "Description for the disguise option " + info.getRawName());
|
.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("")) {
|
for (String e : info.getEnums("")) {
|
||||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.save(e, "Used for the disguise option " + info.getRawName());
|
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()) {
|
for (LibsMsg msg : LibsMsg.values()) {
|
||||||
TranslateType.MESSAGES.save(msg.getRaw());
|
TranslateType.MESSAGES.save(msg.getRaw());
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package me.libraryaddict.disguise.utilities;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
@ -60,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));
|
||||||
}
|
}
|
||||||
@ -134,23 +135,11 @@ public enum TranslateType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String get(String msg) {
|
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())
|
if (msg == null || !LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations())
|
||||||
return msg;
|
return msg;
|
||||||
|
|
||||||
String toReturn = translated.get(msg);
|
String toReturn = translated.get(msg);
|
||||||
|
|
||||||
if (toReturn != null)
|
return toReturn == null ? msg : toReturn;
|
||||||
return toReturn;
|
|
||||||
|
|
||||||
save(msg, comment);
|
|
||||||
|
|
||||||
return msg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user