Use MessageUtils instead of String.format for currency formatting

This commit is contained in:
Carter 2017-06-08 18:33:49 -04:00
parent 2adb136f3d
commit 6015eb7947
2 changed files with 7 additions and 5 deletions

View File

@ -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;
@ -22,7 +23,7 @@ public class Currency {
this.nameSingular = nameSingular;
this.namePlural = namePlural;
this.format = format;
this.formatBalance = "%s %s";
this.formatBalance = "{1} {2}";
}
public Currency(String nameSingular,String namePlural,DecimalFormat format,String formatBalance){
@ -69,10 +70,11 @@ public class Currency {
*/
public String formatAmount(double amount) {
if (amount == 1) {
return String.format(formatBalance, format.format(amount), nameSingular);
return MessageUtils.indexedFormat(formatBalance, format.format(amount), nameSingular);
// return String.format(formatBalance, format.format(amount), nameSingular);
}
return String.format(formatBalance, format.format(amount), namePlural);
return MessageUtils.indexedFormat(formatBalance, format.format(amount), namePlural);
// return String.format(formatBalance, format.format(amount), namePlural);
}
/**

View File

@ -5,7 +5,7 @@ currency:
name:
singular: dollar
plural: dollars
balance-format: '%s %s'
balance-format: '{1} {2}'
format: '0.00'
grouping: 3
grouping-separator: ','