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 9e4cb9a..725954a 100644 --- a/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/Currency.java +++ b/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/Currency.java @@ -1,6 +1,7 @@ package org.appledash.saneeconomy.economy; import com.google.common.base.Strings; +import org.appledash.saneeconomy.utils.MessageUtils; import org.bukkit.configuration.ConfigurationSection; import java.text.DecimalFormat; @@ -16,11 +17,20 @@ public class Currency { private final String nameSingular; private final String namePlural; private final DecimalFormat format; + private final String formatBalance; public Currency(String nameSingular, String namePlural, DecimalFormat format) { this.nameSingular = nameSingular; this.namePlural = namePlural; this.format = format; + this.formatBalance = "{1} {2}"; + } + + public Currency(String nameSingular,String namePlural,DecimalFormat format,String formatBalance){ + this.nameSingular = nameSingular; + this.namePlural = namePlural; + this.format = format; + this.formatBalance = formatBalance; } public static Currency fromConfig(ConfigurationSection config) { @@ -48,7 +58,8 @@ public class Currency { return new Currency( config.getString("name.singular", "dollar"), config.getString("name.plural", "dollars"), - format + format, + config.getString("balance-format","%s %s") ); } @@ -59,10 +70,11 @@ public class Currency { */ public String formatAmount(double amount) { if (amount == 1) { - return String.format("%s %s", format.format(amount), nameSingular); + return MessageUtils.indexedFormat(formatBalance, format.format(amount), nameSingular); +// return String.format(formatBalance, format.format(amount), nameSingular); } - - return String.format("%s %s", format.format(amount), namePlural); + return MessageUtils.indexedFormat(formatBalance, format.format(amount), namePlural); +// return String.format(formatBalance, format.format(amount), namePlural); } /** diff --git a/SaneEconomyCore/src/main/resources/config.yml b/SaneEconomyCore/src/main/resources/config.yml index 5589360..d0cf37c 100644 --- a/SaneEconomyCore/src/main/resources/config.yml +++ b/SaneEconomyCore/src/main/resources/config.yml @@ -5,6 +5,7 @@ currency: name: singular: dollar plural: dollars + balance-format: '{1} {2}' format: '0.00' grouping: 3 grouping-separator: ','