diff --git a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java index 9acaafcb..ec4a66e7 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java @@ -302,13 +302,17 @@ public enum LibsMsg { LibsMsg(String string) { this.string = string; - if (!DisguiseUtilities.hasAdventureTextSupport()) { - for (ChatColor c : ChatColor.values()) { - string = string.replaceAll("<" + c.name().toLowerCase(Locale.ROOT) + ">", "§" + c.getChar()); - } + useString = DisguiseUtilities.hasAdventureTextSupport() ? string : getVanillaFormat(); + } + + public String getVanillaFormat() { + String raw = getRaw(); + + for (ChatColor c : ChatColor.values()) { + raw = raw.replace("<" + c.name().toLowerCase(Locale.ROOT) + ">", "§" + c.getChar()); } - useString = string; + return raw; } public String getRaw() { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateFiller.java b/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateFiller.java index ff530d54..a5b4e52e 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateFiller.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateFiller.java @@ -107,7 +107,7 @@ public class TranslateFiller { .save("DisgiseType", "Used for the disgiuse modify radius command to list all " + "disguisetypes"); for (LibsMsg msg : LibsMsg.values()) { - TranslateType.MESSAGES.save(DisguiseUtilities.translateAlternateColorCodes(msg.getRaw()), "Reference: " + msg.name()); + TranslateType.MESSAGES.save(msg, DisguiseUtilities.translateAlternateColorCodes(msg.getRaw()), "Reference: " + msg.name()); } for (TranslateType type : TranslateType.values()) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateType.java b/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateType.java index 542373d0..c9e420ab 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateType.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateType.java @@ -135,15 +135,31 @@ public enum TranslateType { } public void save(String message, String comment) { - String sanitized = StringEscapeUtils.escapeJava(message.replace(ChatColor.COLOR_CHAR + "", "&")); + save(null, message, comment); + } - toDeDupe.put(sanitized, false); + public void save(LibsMsg orig, String message, String comment) { + toDeDupe.put(StringEscapeUtils.escapeJava(message.replace("§", "&")), false); if (translated.containsKey(message)) { return; } - translated.put(message, message); + String value = message; + + if (orig != null) { + String vanilla = orig.getVanillaFormat(); + + if (translated.containsKey(vanilla) && !vanilla.equals(message) && !translated.get(vanilla).equals(vanilla)) { + value = translated.get(vanilla); + + for (ChatColor color : ChatColor.values()) { + value = value.replace("§" + color.getChar(), "<" + color.name().toLowerCase(Locale.ROOT) + ">"); + } + } + } + + translated.put(message, value); try { boolean exists = getFile().exists(); @@ -169,7 +185,10 @@ public enum TranslateType { } } - writer.write("\n" + (comment != null ? "# " + comment + "\n" : "") + "\"" + sanitized + "\": \"" + sanitized + "\"\n"); + String sanitizedKey = StringEscapeUtils.escapeJava(message.replace("§", "&")); + String sanitized = StringEscapeUtils.escapeJava(value.replace("§", "&")); + + writer.write("\n" + (comment != null ? "# " + comment + "\n" : "") + "\"" + sanitizedKey + "\": \"" + sanitized + "\"\n"); written++; } catch (Exception ex) { ex.printStackTrace();