Bug fixes, more translations
This commit is contained in:
parent
4fe484dc10
commit
27472578cd
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());
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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, " "));
|
||||
}
|
||||
}
|
||||
|
@ -86,10 +86,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;
|
||||
}
|
||||
@ -169,7 +165,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,7 +182,7 @@ 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;
|
||||
|
@ -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() {
|
||||
|
@ -15,16 +15,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());
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
@ -88,6 +89,8 @@ public enum TranslateType {
|
||||
translated.put(message, message);
|
||||
|
||||
message = StringEscapeUtils.escapeJava(message.replaceAll(ChatColor.COLOR_CHAR + "", "&"));
|
||||
String message1 = StringEscapeUtils.escapeJava(
|
||||
StringUtils.reverse(message).replaceAll("s%", "%s").replaceAll(ChatColor.COLOR_CHAR + "", "&"));
|
||||
|
||||
try {
|
||||
boolean exists = file.exists();
|
||||
@ -108,7 +111,7 @@ public enum TranslateType {
|
||||
}
|
||||
|
||||
writer.write("\n" + (comment != null ? "# " + comment + "\n" :
|
||||
"") + "\"" + message + "\": \"" + message + "\"\n");
|
||||
"") + "\"" + message + "\": \"" + message1 + "\"\n");
|
||||
|
||||
writer.close();
|
||||
}
|
||||
@ -134,23 +137,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