mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-01-07 07:41:03 +00:00
Add config option to make currency symbol as a suffix (#3066)
Adds `currency-symbol-suffix` config option to move the currency symbol as a suffix rather than a prefix. Closes #2577.
This commit is contained in:
parent
23f0f98af3
commit
b7eec09307
5 changed files with 25 additions and 2 deletions
|
@ -48,6 +48,8 @@ public interface ISettings extends IConf {
|
|||
|
||||
String getCurrencySymbol();
|
||||
|
||||
boolean isCurrencySymbolSuffixed();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
|
|
@ -151,10 +151,13 @@ public class Kit {
|
|||
|
||||
boolean spew = false;
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||
final boolean currencyIsSuffix = ess.getSettings().isCurrencySymbolSuffixed();
|
||||
final String currencySymbol = ess.getSettings().getCurrencySymbol();
|
||||
List<ItemStack> itemList = new ArrayList<>();
|
||||
for (String kitItem : output.getLines()) {
|
||||
if (kitItem.startsWith(ess.getSettings().getCurrencySymbol())) {
|
||||
BigDecimal value = new BigDecimal(kitItem.substring(ess.getSettings().getCurrencySymbol().length()).trim());
|
||||
if (!currencyIsSuffix ? kitItem.startsWith(ess.getSettings().getCurrencySymbol()) : kitItem.endsWith(ess.getSettings().getCurrencySymbol())) {
|
||||
final String valueString = currencyIsSuffix ? kitItem.substring(0, currencySymbol.length()) : kitItem.substring(currencySymbol.length());
|
||||
BigDecimal value = new BigDecimal(valueString.trim());
|
||||
Trade t = new Trade(value, ess);
|
||||
t.pay(user, OverflowType.DROP);
|
||||
continue;
|
||||
|
|
|
@ -678,6 +678,11 @@ public class Settings implements net.ess3.api.ISettings {
|
|||
return config.getString("currency-symbol", "$").concat("$").substring(0, 1).replaceAll("[0-9]", "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySymbolSuffixed() {
|
||||
return config.getBoolean("currency-symbol-suffix", false);
|
||||
}
|
||||
|
||||
// #easteregg
|
||||
@Override
|
||||
@Deprecated
|
||||
|
|
|
@ -36,6 +36,9 @@ public class NumberUtil {
|
|||
}
|
||||
|
||||
public static String shortCurrency(final BigDecimal value, final IEssentials ess) {
|
||||
if (ess.getSettings().isCurrencySymbolSuffixed()) {
|
||||
return formatAsCurrency(value) + ess.getSettings().getCurrencySymbol();
|
||||
}
|
||||
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
|
||||
}
|
||||
|
||||
|
@ -66,6 +69,9 @@ public class NumberUtil {
|
|||
currency = currency.substring(1);
|
||||
sign = "-";
|
||||
}
|
||||
if (ess.getSettings().isCurrencySymbolSuffixed()) {
|
||||
return sign + tl("currency", currency, ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
return sign + tl("currency", ess.getSettings().getCurrencySymbol(), currency);
|
||||
}
|
||||
|
||||
|
@ -76,6 +82,9 @@ public class NumberUtil {
|
|||
currency = currency.substring(1);
|
||||
sign = "-";
|
||||
}
|
||||
if (ess.getSettings().isCurrencySymbolSuffixed()) {
|
||||
return sign + tl("currency", currency, ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
return sign + tl("currency", ess.getSettings().getCurrencySymbol(), currency);
|
||||
}
|
||||
|
||||
|
|
|
@ -678,6 +678,10 @@ command-costs:
|
|||
# such as accented letters, you MUST save the file as UTF-8, not ANSI.
|
||||
currency-symbol: '$'
|
||||
|
||||
# Enable this to make the currency symbol appear at the end of the amount rather than at the start.
|
||||
# For example, the euro symbol typically appears after the current amount.
|
||||
currency-symbol-suffix: false
|
||||
|
||||
# Set the maximum amount of money a player can have.
|
||||
# The amount is always limited to 10 trillion because of the limitations of a java double.
|
||||
max-money: 10000000000000
|
||||
|
|
Loading…
Reference in a new issue