Add option to hide balances <=0 from baltop (#4226)

Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
Debug 2021-06-12 18:31:39 +02:00 committed by GitHub
parent fa87c74b56
commit 6e5a41a880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -379,6 +379,8 @@ public interface ISettings extends IConf {
boolean isUpdateCheckEnabled();
boolean showZeroBaltop();
enum KeepInvPolicy {
KEEP,
DELETE,

View File

@ -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);
}
}

View File

@ -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<UUID, BalanceTop.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;

View File

@ -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.