Skip to content

Commit

Permalink
Add option to hide balances <=0 from baltop (#4226)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
  • Loading branch information
DebugOk and JRoy authored Jun 12, 2021
1 parent fa87c74 commit 6e5a41a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ public interface ISettings extends IConf {

boolean isUpdateCheckEnabled();

boolean showZeroBaltop();

enum KeepInvPolicy {
KEEP,
DELETE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1858,4 +1858,9 @@ public boolean isRespawnAtBed() {
public boolean isUpdateCheckEnabled() {
return config.getBoolean("update-check", true);
}

@Override
public boolean showZeroBaltop() {
return config.getBoolean("show-zero-baltop", true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand Down Expand Up @@ -103,7 +104,9 @@ public void run() {
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;
Expand Down
5 changes: 5 additions & 0 deletions Essentials/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6e5a41a

Please sign in to comment.