Fix negative playtime stat breaking /baltop (#6074)

Unclear how this happens, possibly a division error?

Fixes #6043
This commit is contained in:
Josh Roy 2025-03-01 13:59:46 -05:00 committed by GitHub
parent 1531cf4146
commit 5bf158c1d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,12 +128,12 @@ public class Commandbalancetop extends EssentialsCommand {
playtime = user.getBase().getStatistic(PLAY_ONE_TICK);
}
// Play time in seconds
final long playTimeSecs = playtime / 20;
final long playTimeSecs = Math.max(playtime / 20, 0);
// 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()) {
playTimeSecs >= ess.getSettings().getBaltopMinPlaytime()) {
newCache.getLines().add(AdventureUtil.miniToLegacy(tlLiteral("balanceTopLine", pos, entry.getValue().getDisplayName(), AdventureUtil.parsed(NumberUtil.displayCurrency(balance, ess)))));
}
pos++;