Skip to content

Commit

Permalink
fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveG committed Dec 4, 2015
1 parent 464fa9e commit 2aea49a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/main/java/cat/nyaa/playtimetracker/Locale.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cat/nyaa/playtimetracker/Reward.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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");
}

Expand Down

0 comments on commit 2aea49a

Please sign in to comment.