Fix bounty set flow to charge contributors after bounty event validation #2

Merged
NotAlexNoyle merged 1 commits from codex/complete-bounty-management-updates into main 2026-02-10 22:57:25 -05:00
NotAlexNoyle commented 2026-02-10 22:56:10 -05:00 (Migrated from github.com)

Motivation

  • Ensure contributors are charged at bet time and prevent bounty state updates when a payment fails.
  • Remove shared mutable command state that could lead to cross-invocation bugs.
  • Correct a message interpolation bug where the over-maximum message used the wrong placeholder value.

Description

  • Reworked /bounty set handling in src/main/java/com/tcoded/playerbountiesplus/command/bounty/BountySetCmd.java to parse the requested amount into a local parsedAmount and compute the final amount locally instead of using a static field.
  • Reordered the flow so input is validated, BountySetEvent is fired, then plugin.getEcoHook().takeEco(...) is called, and only on success the BountyDataManager is updated and saved.
  • Converted the charged/displayed bounty to an integer chargeAndBountyAmount for persistence and messaging to keep display and storage consistent with whole-diamond units.
  • Fixed the over-maximum message so it now uses the configured maximum value instead of the minimum value.

Testing

  • Ran ./gradlew build -x test which failed in this environment due to a Kotlin/Java environment parsing error (IllegalArgumentException: 25.0.1).
  • Ran ./gradlew compileJava --stacktrace which also failed with the same environment-level Kotlin/Java version parsing error.

Codex Task

### Motivation - Ensure contributors are charged at bet time and prevent bounty state updates when a payment fails. - Remove shared mutable command state that could lead to cross-invocation bugs. - Correct a message interpolation bug where the over-maximum message used the wrong placeholder value. ### Description - Reworked `/bounty set` handling in `src/main/java/com/tcoded/playerbountiesplus/command/bounty/BountySetCmd.java` to parse the requested amount into a local `parsedAmount` and compute the final `amount` locally instead of using a static field. - Reordered the flow so input is validated, `BountySetEvent` is fired, then `plugin.getEcoHook().takeEco(...)` is called, and only on success the `BountyDataManager` is updated and saved. - Converted the charged/displayed bounty to an integer `chargeAndBountyAmount` for persistence and messaging to keep display and storage consistent with whole-diamond units. - Fixed the over-maximum message so it now uses the configured `maximum` value instead of the `minimum` value. ### Testing - Ran `./gradlew build -x test` which failed in this environment due to a Kotlin/Java environment parsing error (`IllegalArgumentException: 25.0.1`). - Ran `./gradlew compileJava --stacktrace` which also failed with the same environment-level Kotlin/Java version parsing error. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_698bfc2c2ca4832f80ba229e3ef0e9a2)
Sign in to join this conversation.