Skip to content

Fix negative playtime stat breaking /baltop - #6074

Merged
JRoy merged 4 commits into
EssentialsX:2.xfrom
JRoy:fix/6043
Mar 1, 2025
Merged

Fix negative playtime stat breaking /baltop#6074
JRoy merged 4 commits into
EssentialsX:2.xfrom
JRoy:fix/6043

Conversation

@JRoy

@JRoyJRoy commented Feb 26, 2025

Copy link
Copy Markdown
Member

Unclear how this happens, possibly a division error?

Fixes#6043

Unclear how this happens, possibly a division error?
@JRoyJRoy added type: bugfix PRs that fix bugs in EssentialsX. module: main Issues or PRs for the main Essentials module labels Feb 26, 2025
@JRoyJRoy added this to the 2.21.0 milestone Feb 26, 2025
@JRoy
JRoy requested a review from CopilotMarch 1, 2025 18:57

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR addresses a bug where negative playtime statistics can break the /baltop command by ensuring that playtime values are non-negative before further processing.

  • Clamps playtime seconds to zero using Math.max to avoid negative values.
  • Adjusts the playtime threshold check from > to >= to include borderline cases.

Reviewed Changes

FileDescription
Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.javaUpdates to prevent negative playtime values and adjust the minimum playtime check for /baltop

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java:131

  • Ensure that clamping the playtime to 0 in case of negative values is fully compatible with downstream logic. Consider adding an inline comment explaining why negative playtime values are clamped to improve code clarity.
final long playTimeSecs = Math.max(playtime / 20, 0);

Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java:136

  • [nitpick] Verify that changing the comparison operator from '>' to '>=' for the minimum playtime check is intentional, as it now includes users whose playtime exactly matches the minimum requirement.
playTimeSecs >= ess.getSettings().getBaltopMinPlaytime()) {

@JRoy
JRoy merged commit 5bf158c into EssentialsX:2.xMar 1, 2025
@JRoy
JRoy deleted the fix/6043 branch March 1, 2025 18:59
rewsdjad1 pushed a commit to rewsdjad1/EssentialsXPlus that referenced this pull request Aug 13, 2026
Unclear how this happens, possibly a division error?
FixesEssentialsX#6043
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: mainIssues or PRs for the main Essentials moduletype: bugfixPRs that fix bugs in EssentialsX.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/baltop shows no players

3 participants

@JRoy@mdcfe