fix stat decimal format

This commit is contained in:
Indyuce 2019-09-01 18:59:05 +02:00
parent 389d386d25
commit 51ead6884b
2 changed files with 5 additions and 1 deletions

View File

@ -121,7 +121,7 @@ public enum StatType {
FileConfiguration config = new ConfigFile("stats").getConfig();
for (StatType stat : values()) {
stat.defaultInfo = config.contains("default." + stat.name()) ? new LinearValue(config.getConfigurationSection("default." + stat.name())) : new LinearValue(0, 0);
stat.format = new DecimalFormat(config.contains("decimal-format." + stat.name()) ? config.getString("decimal-format." + stat.name()) : "0.#");
stat.format = MMOCore.plugin.configManager.newFormat(config.contains("decimal-format." + stat.name()) ? config.getString("decimal-format." + stat.name()) : "0.#");
}
}
}

View File

@ -115,6 +115,10 @@ public class ConfigManager {
}
}
public DecimalFormat newFormat(String pattern) {
return new DecimalFormat(pattern, formatSymbols);
}
private char getFirstChar(String str, char defaultChar) {
return str == null || str.isEmpty() ? defaultChar : str.charAt(0);
}