mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 00:58:50 +01:00
Add optional requirements for balance top listing (#5394)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
3f0a412390
commit
57c9edcc0c
@ -421,6 +421,10 @@ public interface ISettings extends IConf {
|
||||
|
||||
Tag getSecondaryColor();
|
||||
|
||||
BigDecimal getBaltopMinBalance();
|
||||
|
||||
long getBaltopMinPlaytime();
|
||||
|
||||
enum KeepInvPolicy {
|
||||
KEEP,
|
||||
DELETE,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<UUID, BalanceTop.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);
|
||||
});
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user