From 2aea49a3df1f2b32862502026c0b4f877931fb93 Mon Sep 17 00:00:00 2001 From: Recursive G Date: Fri, 4 Dec 2015 00:42:12 -0600 Subject: [PATCH] fix #2 --- .../java/cat/nyaa/playtimetracker/Locale.java | 19 ++++++++++++------- .../java/cat/nyaa/playtimetracker/Reward.java | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/cat/nyaa/playtimetracker/Locale.java b/src/main/java/cat/nyaa/playtimetracker/Locale.java index 1e99172..fd7c9e7 100644 --- a/src/main/java/cat/nyaa/playtimetracker/Locale.java +++ b/src/main/java/cat/nyaa/playtimetracker/Locale.java @@ -1,40 +1,45 @@ package cat.nyaa.playtimetracker; +import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; public class Locale { private static ConfigurationSection lang; private static String prefix; + private static String getConfigStringWithColor(ConfigurationSection section, String key) { + return ChatColor.translateAlternateColorCodes('&', section.getString(key)); + } + public static void init(ConfigurationSection langSection) { lang = langSection; - prefix = lang.getString("prefix"); + prefix = getConfigStringWithColor(lang, "prefix"); } public static String get(String name, String... args) { - return prefix + String.format(lang.getString(name), args); + return prefix + String.format(getConfigStringWithColor(lang, name), args); } public static String formatTime(long ms) { ConfigurationSection s = lang.getConfigurationSection("statistic-time-format"); String str = ""; if (ms == 0) - return s.getString("zero"); + return getConfigStringWithColor(s,"zero"); if (ms > 0) { - str = String.format(s.getString("ms"), ms % 1000) + str; + str = String.format(getConfigStringWithColor(s,"ms"), ms % 1000) + str; ms = Math.floorDiv(ms, 1000); } if (ms > 0) { - str = String.format(s.getString("s"), ms % 60) + str; + str = String.format(getConfigStringWithColor(s,"s"), ms % 60) + str; ms = Math.floorDiv(ms, 60); } if (ms > 0) { - str = String.format(s.getString("m"), ms % 60) + str; + str = String.format(getConfigStringWithColor(s,"m"), ms % 60) + str; ms = Math.floorDiv(ms, 60); } if (ms > 0) { - str = String.format(s.getString("h"), ms) + str; + str = String.format(getConfigStringWithColor(s,"h"), ms) + str; } return str; diff --git a/src/main/java/cat/nyaa/playtimetracker/Reward.java b/src/main/java/cat/nyaa/playtimetracker/Reward.java index 75ad7a5..7d2e345 100644 --- a/src/main/java/cat/nyaa/playtimetracker/Reward.java +++ b/src/main/java/cat/nyaa/playtimetracker/Reward.java @@ -1,6 +1,7 @@ package cat.nyaa.playtimetracker; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; @@ -13,7 +14,7 @@ public String getDescription() { } public Reward(ConfigurationSection s) { - description = s.getString("description"); + description = ChatColor.translateAlternateColorCodes('&', s.getString("description")); command = s.getString("command"); }