Uses Economy.format to display costs
This commit is contained in:
@ -170,9 +170,8 @@ public class SignListener implements Listener {
|
||||
* @return <p>The message with the cost instead of the cost placeholder</p>
|
||||
*/
|
||||
private String replaceCost(double cost, TranslatableMessage message) {
|
||||
String unit = EconomyManager.getCurrency(cost != 1);
|
||||
return String.format(PaidSigns.getStringFormatter().replacePlaceholders(message,
|
||||
new String[]{"{cost}", "{unit}"}, new String[]{"%.2f", "%s"}), cost, unit);
|
||||
return PaidSigns.getStringFormatter().replacePlaceholder(message,
|
||||
"{cost}", EconomyManager.format(cost));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,17 +35,13 @@ public final class EconomyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the used currency
|
||||
* Formats the given amount of currency according to the economy plugin's format
|
||||
*
|
||||
* @param plural <p>Whether to get the plural name or the singular name</p>
|
||||
* @return <p>The name of the used currency</p>
|
||||
* @param amount <p>The amount of currency to format</p>
|
||||
* @return <p>The formatted string</p>
|
||||
*/
|
||||
public static String getCurrency(boolean plural) {
|
||||
if (plural) {
|
||||
return economy.currencyNamePlural();
|
||||
} else {
|
||||
return economy.currencyNameSingular();
|
||||
}
|
||||
public static String format(double amount) {
|
||||
return economy.format(amount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,10 +162,9 @@ public final class TrackedSignManager {
|
||||
}
|
||||
EconomyManager.deposit(offlinePlayer, refundSum);
|
||||
if (offlinePlayer instanceof Player player) {
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(player, String.format(
|
||||
PaidSigns.getStringFormatter().replacePlaceholders(PaidSignsTranslatableMessage.SUCCESS_REFUNDED,
|
||||
new String[]{"{cost}", "{unit}"}, new String[]{"%.2f", "%s"}), refundSum,
|
||||
EconomyManager.getCurrency(refundSum != 1)));
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(player,
|
||||
PaidSigns.getStringFormatter().replacePlaceholder(PaidSignsTranslatableMessage.SUCCESS_REFUNDED,
|
||||
"{cost}", EconomyManager.format(refundSum)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user