From 97939ff379e427f8b62d7bc6af61923a21b6ecce Mon Sep 17 00:00:00 2001 From: xHyroM Date: Wed, 30 Aug 2023 13:53:27 +0200 Subject: [PATCH] feat(bukkit): add balance_formatted --- .../bukkit/hooks/PlaceholderAPIExpansion.java | 11 ++++++++--- .../lighteco/common/model/currency/Currency.java | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/hooks/PlaceholderAPIExpansion.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/hooks/PlaceholderAPIExpansion.java index 68ce971..a4162ad 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/hooks/PlaceholderAPIExpansion.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/hooks/PlaceholderAPIExpansion.java @@ -40,10 +40,15 @@ public class PlaceholderAPIExpansion extends PlaceholderExpansion { Currency currency = this.plugin.getCurrencyManager().getIfLoaded(currencyIdentifier); if (currency == null) return null; - if (type.equalsIgnoreCase("balance")) { - User user = this.plugin.getUserManager().loadUser(player.getUniqueId()).join(); + User user = this.plugin.getUserManager().loadUser(player.getUniqueId()).join(); - return user.getBalance(currency).toPlainString(); + switch (type.toLowerCase()) { + case "balance" -> { + return user.getBalance(currency).toPlainString(); + } + case "balance_formatted" -> { + return currency.format(user.getBalance(currency)); + } } return null; diff --git a/common/src/main/java/dev/xhyrom/lighteco/common/model/currency/Currency.java b/common/src/main/java/dev/xhyrom/lighteco/common/model/currency/Currency.java index f6595e4..92a3262 100644 --- a/common/src/main/java/dev/xhyrom/lighteco/common/model/currency/Currency.java +++ b/common/src/main/java/dev/xhyrom/lighteco/common/model/currency/Currency.java @@ -24,6 +24,10 @@ public class Currency { return proxy.getType(); } + public String format(BigDecimal amount) { + return proxy.format(amount); + } + public BigDecimal getDefaultBalance() { return proxy.getDefaultBalance(); }