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>
|
* @return <p>The message with the cost instead of the cost placeholder</p>
|
||||||
*/
|
*/
|
||||||
private String replaceCost(double cost, TranslatableMessage message) {
|
private String replaceCost(double cost, TranslatableMessage message) {
|
||||||
String unit = EconomyManager.getCurrency(cost != 1);
|
return PaidSigns.getStringFormatter().replacePlaceholder(message,
|
||||||
return String.format(PaidSigns.getStringFormatter().replacePlaceholders(message,
|
"{cost}", EconomyManager.format(cost));
|
||||||
new String[]{"{cost}", "{unit}"}, new String[]{"%.2f", "%s"}), cost, unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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>
|
* @param amount <p>The amount of currency to format</p>
|
||||||
* @return <p>The name of the used currency</p>
|
* @return <p>The formatted string</p>
|
||||||
*/
|
*/
|
||||||
public static String getCurrency(boolean plural) {
|
public static String format(double amount) {
|
||||||
if (plural) {
|
return economy.format(amount);
|
||||||
return economy.currencyNamePlural();
|
|
||||||
} else {
|
|
||||||
return economy.currencyNameSingular();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,10 +162,9 @@ public final class TrackedSignManager {
|
|||||||
}
|
}
|
||||||
EconomyManager.deposit(offlinePlayer, refundSum);
|
EconomyManager.deposit(offlinePlayer, refundSum);
|
||||||
if (offlinePlayer instanceof Player player) {
|
if (offlinePlayer instanceof Player player) {
|
||||||
PaidSigns.getStringFormatter().displaySuccessMessage(player, String.format(
|
PaidSigns.getStringFormatter().displaySuccessMessage(player,
|
||||||
PaidSigns.getStringFormatter().replacePlaceholders(PaidSignsTranslatableMessage.SUCCESS_REFUNDED,
|
PaidSigns.getStringFormatter().replacePlaceholder(PaidSignsTranslatableMessage.SUCCESS_REFUNDED,
|
||||||
new String[]{"{cost}", "{unit}"}, new String[]{"%.2f", "%s"}), refundSum,
|
"{cost}", EconomyManager.format(refundSum)));
|
||||||
EconomyManager.getCurrency(refundSum != 1)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ en:
|
|||||||
SUCCESS_REMOVED_PAID_SIGN: "&bSuccessfully removed paid sign"
|
SUCCESS_REMOVED_PAID_SIGN: "&bSuccessfully removed paid sign"
|
||||||
SUCCESS_REMOVED_CONDITION: "&bSuccessfully removed paid sign condition"
|
SUCCESS_REMOVED_CONDITION: "&bSuccessfully removed paid sign condition"
|
||||||
SUCCESS_RELOADED: "&bSuccessfully reloaded configuration"
|
SUCCESS_RELOADED: "&bSuccessfully reloaded configuration"
|
||||||
SUCCESS_PAID_FOR_SIGN: "&bYou paid &3{cost} {unit} &bto create the sign"
|
SUCCESS_PAID_FOR_SIGN: "&bYou paid &3{cost} &bto create the sign"
|
||||||
SUCCESS_REFUNDED: "&bYou were refunded &3{cost} {unit} &bfor your broken sign"
|
SUCCESS_REFUNDED: "&bYou were refunded &3{cost} &bfor your broken sign"
|
||||||
PAID_SIGNS_INFO: |
|
PAID_SIGNS_INFO: |
|
||||||
&f---&3Paid signs&f---
|
&f---&3Paid signs&f---
|
||||||
{signs}{nextPagePrompt}
|
{signs}{nextPagePrompt}
|
||||||
@ -46,6 +46,6 @@ en:
|
|||||||
ERROR_INVALID_INPUT: "&bInvalid input: {input}"
|
ERROR_INVALID_INPUT: "&bInvalid input: {input}"
|
||||||
ERROR_PAID_SIGN_NOT_FOUND: "&bNo such paid sign exists"
|
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_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_INVALID_REGULAR_EXPRESSION: "&bThe provided regular expression is invalid"
|
||||||
ERROR_PROPERTY_NOT_RECOGNIZED: "&bThe property you tried to change was not recognized"
|
ERROR_PROPERTY_NOT_RECOGNIZED: "&bThe property you tried to change was not recognized"
|
Loading…
Reference in New Issue
Block a user