Fix donated points calculation using stale stored total instead of current block values#438
Merged
Merged
Conversation
…block config values Instead of reading the stale accumulated donatedPoints value stored in the database (which was calculated at donation-time using then-current block values), dynamically recalculate the donated points from the donatedBlocks map using the current block config values on every level calculation. This fixes incorrect level calculations when block config values change after blocks have been donated. Previously the stored total could be less than a single block type's current contribution, as seen in the issue where Iron Block x 3,553 = 49,742 points but the total donated points reported was only 49,348. Also update the getReport() donated block section to use getValue(world, key) for world-specific block value lookups, consistent with how the calculation works. Fixes #nnn Agent-Logs-Url: https://github.com/BentoBoxWorld/Level/sessions/8d20bea9-7362-4af9-aa27-e0ae175eec2a Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix incorrect level calculation for donation
Fix donated points calculation using stale stored total instead of current block values
May 16, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The donated block points were accumulated in the DB at donation-time block config values. When an admin later changes block values,
tidyUp()was still using the stale stored total — causing level calculations where the reported total was less than a single block type's current contribution (e.g. total = 49,348 while Iron Block alone = 3,553 × 14 = 49,742).Changes
IslandLevelCalculator.tidyUp(): Replace the stalegetDonatedPoints()DB read with a dynamic recalculation from thedonatedBlockscount map × current block config values. Keys are lowercased to match the stored config format.getReport(): Updated the per-block value lookup to usegetValue(world, key)(world-specific) instead of the flatgetBlockValues()map, making the report consistent with the calculation.