From 6e5a41a880af6c74e4265b53afa8b041cfc600b2 Mon Sep 17 00:00:00 2001 From: Debug <49997488+DebugOk@users.noreply.github.com> Date: Sat, 12 Jun 2021 18:31:39 +0200 Subject: [PATCH] Add option to hide balances <=0 from baltop (#4226) Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com> --- .../src/main/java/com/earth2me/essentials/ISettings.java | 2 ++ .../src/main/java/com/earth2me/essentials/Settings.java | 5 +++++ .../com/earth2me/essentials/commands/Commandbalancetop.java | 5 ++++- Essentials/src/main/resources/config.yml | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java index 15a2ef450..017af75fb 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java @@ -379,6 +379,8 @@ public interface ISettings extends IConf { boolean isUpdateCheckEnabled(); + boolean showZeroBaltop(); + enum KeepInvPolicy { KEEP, DELETE, diff --git a/Essentials/src/main/java/com/earth2me/essentials/Settings.java b/Essentials/src/main/java/com/earth2me/essentials/Settings.java index da2591d52..52b3da3f1 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -1858,4 +1858,9 @@ public class Settings implements net.ess3.api.ISettings { public boolean isUpdateCheckEnabled() { return config.getBoolean("update-check", true); } + + @Override + public boolean showZeroBaltop() { + return config.getBoolean("show-zero-baltop", true); + } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java index b79b792d5..2f5af8367 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java @@ -8,6 +8,7 @@ import com.google.common.collect.Lists; import net.essentialsx.api.v2.services.BalanceTop; import org.bukkit.Server; +import java.math.BigDecimal; import java.text.DateFormat; import java.util.Calendar; import java.util.Collections; @@ -103,7 +104,9 @@ public class Commandbalancetop extends EssentialsCommand { newCache.getLines().add(tl("serverTotal", NumberUtil.displayCurrency(ess.getBalanceTop().getBalanceTopTotal(), ess))); int pos = 1; for (final Map.Entry entry : ess.getBalanceTop().getBalanceTopCache().entrySet()) { - newCache.getLines().add(tl("balanceTopLine", pos, entry.getValue().getDisplayName(), NumberUtil.displayCurrency(entry.getValue().getBalance(), ess))); + if (ess.getSettings().showZeroBaltop() || entry.getValue().getBalance().compareTo(BigDecimal.ZERO) <= 0) { + newCache.getLines().add(tl("balanceTopLine", pos, entry.getValue().getDisplayName(), NumberUtil.displayCurrency(entry.getValue().getBalance(), ess))); + } pos++; } cache = newCache; diff --git a/Essentials/src/main/resources/config.yml b/Essentials/src/main/resources/config.yml index 555e9646c..8e575d06c 100644 --- a/Essentials/src/main/resources/config.yml +++ b/Essentials/src/main/resources/config.yml @@ -781,6 +781,11 @@ minimum-pay-amount: 0.001 # Enable this to block users who try to /pay another user which ignore them. pay-excludes-ignore-list: false +# Whether or not users with a balance less than or equal to $0 should be shown in balance-top. +# Setting to false will not show people with balances <= 0 in balance-top. +# NOTE: After reloading the config, you must also run '/baltop force' for this to appear +show-zero-baltop: true + # The format of currency, excluding symbols. See currency-symbol-format-locale for symbol configuration. # # "#,##0.00" is how the majority of countries display currency.