Skip to content

Conversation

@JRoy
Copy link
Member

@JRoy JRoy commented Feb 26, 2025

Unclear how this happens, possibly a division error?

Fixes #6043

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

Copilot AI left a comment

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

File Description
Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java Updates 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.x Mar 1, 2025
1 check passed
@JRoy JRoy deleted the fix/6043 branch March 1, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: main Issues or PRs for the main Essentials module type: bugfix PRs that fix bugs in EssentialsX.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/baltop shows no players

2 participants