Repository navigation
fix: prevent stale and invalid amounts in money requirements - #318
Open
kripypastishka wants to merge 1 commit into
Open
kripypastishka wants to merge 1 commit into
kripypastishka wants to merge 1 commit into
Conversation
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.
Fix stale and invalid amounts in money requirements
Summary
Fixes an issue in
HasMoneyRequirementwhere the amount resolved from a placeholder could persist between evaluations, potentially causing incorrect permission or economy requirement results.Problem
Previously, the requirement stored the resolved amount in a mutable instance field.
When a placeholder returned an invalid numeric value, parsing failed, but the requirement continued evaluating using the previously stored amount.
Since requirement instances can be reused across players and evaluations, this could lead to unintended results.
Changes
requiredAmountvariable for each evaluation.falsewhen placeholder parsing fails.NaN, and infinite amounts.Security Impact
Prevents stale values from affecting money-based access checks and ensures that invalid amounts fail closed.
Compatibility
No configuration, database schema, or public API changes are required.
Invalid or negative amounts are now rejected instead of being passed to the economy provider.
Testing
The original and modified logic were checked using a standalone Java regression test with mocked dependencies.
Not yet verified:
Recommendations
Before merging, run
./gradlew buildand verify bothhas moneyand!has moneyrequirements with valid, invalid, and dynamically changing placeholder values.Risk
Low to moderate. The change is localized to money requirement evaluation.