mirror of
https://github.com/AppleDash/SaneEconomy.git
synced 2024-11-26 12:05:46 +01:00
Add proper grouping support to currency formats.
This commit is contained in:
parent
ba10f3666f
commit
cd28df2112
@ -3,6 +3,7 @@ package org.appledash.saneeconomy.economy;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
|
||||
/**
|
||||
* Created by AppleDash on 6/13/2016.
|
||||
@ -22,10 +23,24 @@ public class Currency {
|
||||
}
|
||||
|
||||
public static Currency fromConfig(ConfigurationSection config) {
|
||||
DecimalFormat format = new DecimalFormat(config.getString("format", "0.00"));
|
||||
|
||||
if (config.getInt("grouping", 0) > 0) {
|
||||
DecimalFormatSymbols symbols = format.getDecimalFormatSymbols();
|
||||
if (symbols.getDecimalSeparator() == ',') { // French
|
||||
symbols.setGroupingSeparator(' ');
|
||||
} else {
|
||||
symbols.setGroupingSeparator(',');
|
||||
}
|
||||
format.setDecimalFormatSymbols(symbols);
|
||||
format.setGroupingUsed(true);
|
||||
format.setGroupingSize(3);
|
||||
}
|
||||
|
||||
return new Currency(
|
||||
config.getString("name.singular", "dollar"),
|
||||
config.getString("name.plural", "dollars"),
|
||||
new DecimalFormat(config.getString("format", "0.00"))
|
||||
format
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ currency:
|
||||
singular: dollar
|
||||
plural: dollars
|
||||
format: '0.00'
|
||||
grouping: 3
|
||||
|
||||
chat:
|
||||
prefix: '&b[&9Economy&b]&r '
|
||||
|
Loading…
Reference in New Issue
Block a user