Skip to content

Fix review findings: NPE guards, formula [level] variable, ChatInput bugs, loop optimizations#81

Merged
tastybento merged 3 commits intodevelopfrom
copilot/sub-pr-53
Apr 12, 2026
Merged

Fix review findings: NPE guards, formula [level] variable, ChatInput bugs, loop optimizations#81
tastybento merged 3 commits intodevelopfrom
copilot/sub-pr-53

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 11, 2026

Addresses all 11 review comments from the PR #53 review thread.

NPE guard for legacy upgrades in PanelClick

Legacy upgrades left ownDescription stale when maxed (upgradeValues=null but ownDescription!=null), bypassing the maxed-out guard and causing NPE in canUpgrade(). All 5 legacy upgrade classes now clear ownDescription when maxed.

Formula [level] variable hard-coded to 0.0

MoneyPrice, IslandLevelPrice, RangeReward, and LimitsReward all bound [level] to 0.0, making any level-dependent formula (e.g. 100*[level]) evaluate to zero. Added int currentLevel parameter to Price.canPay/pay and Reward.apply:

// Before
public abstract boolean canPay(UpgradesAddon addon, User user, Island island, PriceDB priceDB);
// After
public abstract boolean canPay(UpgradesAddon addon, User user, Island island, PriceDB priceDB, int currentLevel);

DatabaseUpgrade now passes the actual level through to all price/reward evaluations.

ChatInput bugs

  • getFailedValidationText() returned raw user input instead of the invalidText parameter
  • Escape-sequence cancellation never notified the consumer, leaving callers (e.g. AdminPanel.addUpgrade) in limbo. Now uses a consumerCalled flag so the abandonment listener calls consumer.accept(null) on escape/timeout without double-firing on valid input

AdminPanel null guard

addUpgrade consumer now guards against null input from cancelled conversations instead of concatenating null into the uniqueId.

Misc

  • Removed debug log("permission: ...") from CommandUpgrade.isShowed() (hot path during panel render)
  • Hoisted UpgradesData lookup out of loop in SpawnerUpgradeListener and CropGrowthListener (BlockGrowEvent/SpawnerSpawnEvent fire frequently)
  • Replaced fullwidth with & in ja.yml for correct Minecraft color code parsing

Copilot AI and others added 2 commits April 11, 2026 23:33
… debug log, loop optimizations, ja.yml

Agent-Logs-Url: https://github.com/BentoBoxWorld/Upgrades/sessions/a43eb321-a212-416e-994c-4fa6af167be8

Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Copilot AI changed the title [WIP] Release 0.3.0 Fix review findings: NPE guards, formula [level] variable, ChatInput bugs, loop optimizations Apr 11, 2026
Copilot AI requested a review from tastybento April 11, 2026 23:36
@tastybento tastybento marked this pull request as ready for review April 11, 2026 23:38
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4.2% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@tastybento tastybento merged commit 8c79ef2 into develop Apr 12, 2026
2 of 3 checks passed
@tastybento tastybento deleted the copilot/sub-pr-53 branch April 12, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants