From 1545bcacad016223531ed24c448536d0597f8526 Mon Sep 17 00:00:00 2001 From: AppleDash Date: Wed, 14 Jun 2017 10:39:43 -0400 Subject: [PATCH] Make balance-format work properly --- .../saneeconomy/economy/Currency.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/Currency.java b/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/Currency.java index 725954a..c7c42c2 100644 --- a/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/Currency.java +++ b/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/Currency.java @@ -17,20 +17,17 @@ public class Currency { private final String nameSingular; private final String namePlural; private final DecimalFormat format; - private final String formatBalance; + private final String balanceFormat; public Currency(String nameSingular, String namePlural, DecimalFormat format) { - this.nameSingular = nameSingular; - this.namePlural = namePlural; - this.format = format; - this.formatBalance = "{1} {2}"; + this(nameSingular, namePlural, format, "{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.namePlural = namePlural; this.format = format; - this.formatBalance = formatBalance; + this.balanceFormat = balanceFormat; } public static Currency fromConfig(ConfigurationSection config) { @@ -59,7 +56,7 @@ public class Currency { config.getString("name.singular", "dollar"), config.getString("name.plural", "dollars"), 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) { if (amount == 1) { - return MessageUtils.indexedFormat(formatBalance, format.format(amount), nameSingular); -// return String.format(formatBalance, format.format(amount), nameSingular); + return MessageUtils.indexedFormat(balanceFormat, 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); } /**