Make balance-format work properly

This commit is contained in:
AppleDash 2017-06-14 10:39:43 -04:00
parent 921734241e
commit 1545bcacad

View File

@ -17,20 +17,17 @@ public class Currency {
private final String nameSingular; private final String nameSingular;
private final String namePlural; private final String namePlural;
private final DecimalFormat format; private final DecimalFormat format;
private final String formatBalance; private final String balanceFormat;
public Currency(String nameSingular, String namePlural, DecimalFormat format) { public Currency(String nameSingular, String namePlural, DecimalFormat format) {
this.nameSingular = nameSingular; this(nameSingular, namePlural, format, "{1} {2}");
this.namePlural = namePlural;
this.format = format;
this.formatBalance = "{1} {2}";
} }
public Currency(String nameSingular,String namePlural,DecimalFormat format,String formatBalance){ public Currency(String nameSingular, String namePlural, DecimalFormat format, String balanceFormat) {
this.nameSingular = nameSingular; this.nameSingular = nameSingular;
this.namePlural = namePlural; this.namePlural = namePlural;
this.format = format; this.format = format;
this.formatBalance = formatBalance; this.balanceFormat = balanceFormat;
} }
public static Currency fromConfig(ConfigurationSection config) { public static Currency fromConfig(ConfigurationSection config) {
@ -59,7 +56,7 @@ public class Currency {
config.getString("name.singular", "dollar"), config.getString("name.singular", "dollar"),
config.getString("name.plural", "dollars"), config.getString("name.plural", "dollars"),
format, format,
config.getString("balance-format","%s %s") config.getString("balance-format", "{1} {2}")
); );
} }
@ -70,11 +67,10 @@ public class Currency {
*/ */
public String formatAmount(double amount) { public String formatAmount(double amount) {
if (amount == 1) { if (amount == 1) {
return MessageUtils.indexedFormat(formatBalance, format.format(amount), nameSingular); return MessageUtils.indexedFormat(balanceFormat, format.format(amount), nameSingular);
// return String.format(formatBalance, format.format(amount), nameSingular);
} }
return MessageUtils.indexedFormat(formatBalance, format.format(amount), namePlural);
// return String.format(formatBalance, format.format(amount), namePlural); return MessageUtils.indexedFormat(balanceFormat, format.format(amount), namePlural);
} }
/** /**