Bug fixes, more translations
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user