Uses Economy.format to display costs
This commit is contained in:
parent
8e3a71a489
commit
7355b7fc60
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@ en:
|
||||
SUCCESS_REMOVED_PAID_SIGN: "&bSuccessfully removed paid sign"
|
||||
SUCCESS_REMOVED_CONDITION: "&bSuccessfully removed paid sign condition"
|
||||
SUCCESS_RELOADED: "&bSuccessfully reloaded configuration"
|
||||
SUCCESS_PAID_FOR_SIGN: "&bYou paid &3{cost} {unit} &bto create the sign"
|
||||
SUCCESS_REFUNDED: "&bYou were refunded &3{cost} {unit} &bfor your broken sign"
|
||||
SUCCESS_PAID_FOR_SIGN: "&bYou paid &3{cost} &bto create the sign"
|
||||
SUCCESS_REFUNDED: "&bYou were refunded &3{cost} &bfor your broken sign"
|
||||
PAID_SIGNS_INFO: |
|
||||
&f---&3Paid signs&f---
|
||||
{signs}{nextPagePrompt}
|
||||
@ -46,6 +46,6 @@ en:
|
||||
ERROR_INVALID_INPUT: "&bInvalid input: {input}"
|
||||
ERROR_PAID_SIGN_NOT_FOUND: "&bNo such paid sign exists"
|
||||
ERROR_NO_SUCH_CONDITION: "&bThe paid sign you specified has no condition for line {line}"
|
||||
ERROR_CANNOT_AFFORD: "&bYou cannot afford to create this sign. The cost is {cost} {unit}"
|
||||
ERROR_CANNOT_AFFORD: "&bYou cannot afford to create this sign. The cost is {cost}"
|
||||
ERROR_INVALID_REGULAR_EXPRESSION: "&bThe provided regular expression is invalid"
|
||||
ERROR_PROPERTY_NOT_RECOGNIZED: "&bThe property you tried to change was not recognized"
|
Loading…
Reference in New Issue
Block a user