diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currency.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currency.kt index c741b6a..068b365 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currency.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currency.kt @@ -120,6 +120,15 @@ class Currency( } ) + PlaceholderManager.registerPlaceholder( + PlayerPlaceholder( + plugin, + "${id}_commas" + ) { + it.getBalance(this).formatWithCommas() + } + ) + PlaceholderManager.registerPlaceholder( PlayerPlaceholder( plugin, @@ -182,6 +191,10 @@ fun BigDecimal.formatWithExtension(): String { } } +fun BigDecimal.formatWithCommas(): String { + return DecimalFormat("#,###.00").format(this) +} + fun OfflinePlayer.getBalance(currency: Currency): BigDecimal { return this.profile.read(currency.key) } diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 8425987..016335f 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -9,6 +9,7 @@ # Placeholders: # %ecobits_% - The balance of a certain currency +# %ecobits__commas% - The balance with commas of a certain currency # %ecobits__formatted% - The formatted balance of a certain currency # %ecobits__max% - The max balance of a certain currency # %ecobits__default% - The default balance of a certain currency