diff --git a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java index cbeee9328..41eb5531c 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java @@ -421,6 +421,10 @@ public interface ISettings extends IConf { Tag getSecondaryColor(); + BigDecimal getBaltopMinBalance(); + + long getBaltopMinPlaytime(); + 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 15a4c6ef9..d57e5d913 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -2030,4 +2030,14 @@ public class Settings implements net.ess3.api.ISettings { } return null; } + + @Override + public BigDecimal getBaltopMinBalance() { + return config.getBigDecimal("baltop-requirements.minimum-balance", BigDecimal.ZERO); + } + + @Override + public long getBaltopMinPlaytime() { + return config.getLong("baltop-requirements.minimum-playtime", 0); + } } 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 2135163af..6ded4a197 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java @@ -1,13 +1,17 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.CommandSource; +import com.earth2me.essentials.User; import com.earth2me.essentials.textreader.SimpleTextInput; import com.earth2me.essentials.textreader.TextPager; import com.earth2me.essentials.utils.AdventureUtil; +import com.earth2me.essentials.utils.EnumUtil; import com.earth2me.essentials.utils.NumberUtil; import com.google.common.collect.Lists; import net.essentialsx.api.v2.services.BalanceTop; +import org.bukkit.Bukkit; import org.bukkit.Server; +import org.bukkit.Statistic; import org.bukkit.command.BlockCommandSender; import java.math.BigDecimal; @@ -113,14 +117,29 @@ public class Commandbalancetop extends EssentialsCommand { newCache.getLines().add(AdventureUtil.miniToLegacy(tlLiteral("serverTotal", AdventureUtil.parsed(NumberUtil.displayCurrency(ess.getBalanceTop().getBalanceTopTotal(), ess))))); int pos = 1; for (final Map.Entry entry : ess.getBalanceTop().getBalanceTopCache().entrySet()) { - if (ess.getSettings().showZeroBaltop() || entry.getValue().getBalance().compareTo(BigDecimal.ZERO) > 0) { - newCache.getLines().add(AdventureUtil.miniToLegacy(tlLiteral("balanceTopLine", pos, entry.getValue().getDisplayName(), AdventureUtil.parsed(NumberUtil.displayCurrency(entry.getValue().getBalance(), ess))))); + final BigDecimal balance = entry.getValue().getBalance(); + final User user = ess.getUser(entry.getKey()); + + final Statistic PLAY_ONE_TICK = EnumUtil.getStatistic("PLAY_ONE_MINUTE", "PLAY_ONE_TICK"); + final long playtime; + if (user.getBase() == null || !user.getBase().isOnline()) { + playtime = Bukkit.getServer().getOfflinePlayer(entry.getKey()).getStatistic(PLAY_ONE_TICK); + } else { + playtime = user.getBase().getStatistic(PLAY_ONE_TICK); + } + // Play time in seconds + final long playTimeSecs = playtime / 20; + + // Checking if player meets the requirements of minimum balance and minimum playtime to be listed in baltop list + if ((ess.getSettings().showZeroBaltop() || balance.compareTo(BigDecimal.ZERO) > 0) + && balance.compareTo(ess.getSettings().getBaltopMinBalance()) >= 0 && + playTimeSecs > ess.getSettings().getBaltopMinPlaytime()) { + newCache.getLines().add(AdventureUtil.miniToLegacy(tlLiteral("balanceTopLine", pos, entry.getValue().getDisplayName(), AdventureUtil.parsed(NumberUtil.displayCurrency(balance, ess))))); } pos++; } cache = newCache; } - outputCache(sender, page); }); } diff --git a/Essentials/src/main/resources/config.yml b/Essentials/src/main/resources/config.yml index b796a51b2..cec329546 100644 --- a/Essentials/src/main/resources/config.yml +++ b/Essentials/src/main/resources/config.yml @@ -860,6 +860,12 @@ pay-excludes-ignore-list: false # NOTE: After reloading the config, you must also run '/baltop force' for this to appear show-zero-baltop: true +# Requirements which must be met by the player to get their name shown in the balance top list. +# Playtime is in seconds. +baltop-requirements: + minimum-balance: 0 + minimum-playtime: 0 + # The format of currency, excluding symbols. See currency-symbol-format-locale for symbol configuration. # # "#,##0.00" is how the majority of countries display currency.