Skip to content

Start a new exhaustion period when the cooldown ends - #176

Merged
tastybento merged 2 commits into
developfrom
fix/exhaustion-cooldown-resets-period
Nov 17, 2026
Merged

tastybento merged 2 commits into
developfrom
fix/exhaustion-cooldown-resets-period

Conversation

@tastybento

Copy link
Copy Markdown
Member

Summary

An admin asked on Discord how to change the generator exhaustion cooldown. While checking, I found that exhaustion.cooldown was ignored whenever it was shorter than exhaustion.period.

Bug: in StoneGeneratorManager.canGenerateBlock, the block count was reset only when the period ended. When a cooldown shorter than the period expired, the count was still at the limit, so the next attempt put the generator straight back on cooldown. In practice the generator stayed stopped until the cooldown was over and the period had ended, whichever was later. For example, with period: 60, cooldown: 10, a generator that hit its limit after 5 minutes stayed stopped for about 55 minutes instead of 10.

Fix:

  • An expired cooldown now starts a new period with the count reset to 0.
  • cooldown: 0 still means "wait until the period ends": the generator is held until the period end. The generator-exhausted message now also shows the right minutes left in that case. Before, it showed 0.
  • Updated the exhaustion.cooldown comment in config.yml to describe both cases.

Behaviour is unchanged for the default settings (cooldown: 1440 ≥ period: 60).

Test plan

  • New test: a cooldown shorter than the period lets the generator work again with a fresh count once the cooldown expires
  • New test: cooldown: 0 blocks until the period ends, then resumes
  • mvn test: 167 tests, 0 failures

Docs follow-up: BentoBoxWorld/docs#136 describes the current (pre-fix) behaviour. Its "How it works" step 5 should be updated once this is released.

🤖 Generated with Claude Code

tastybento and others added 2 commits November 16, 2026 20:32
A cooldown shorter than the exhaustion period did nothing: when it
expired the block count was still at the limit, so the generator went
straight back on cooldown until the period ended. Now an expired
cooldown starts a fresh period with the count reset to 0.

A cooldown of 0 keeps its previous meaning (wait until the period ends)
by holding the generator until the period end, which also makes the
generator-exhausted message show the correct minutes remaining.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The number formatter used owner.getLocale(), but owner is null on spawn
islands and islands without an owner. Format with the purchasing user's
locale instead: they are the one who receives the messages.

Fixes Sonar java:S2259.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tastybento

Copy link
Copy Markdown
Member Author

Also fixed the Sonar S2259 issue that this PR touched: canPurchaseGenerator threw a NullPointerException on spawn and unowned islands (owner.getLocale() with owner == null). It now formats numbers in the purchasing user's locale, since they receive the messages. Added two tests that failed before the fix. mvn test: 169 passed.

@sonarqubecloud

Copy link
Copy Markdown

@tastybento
tastybento merged commit 03ce05f into develop Nov 17, 2026
4 checks passed
tastybento added a commit that referenced this pull request Nov 17, 2026
Reliability (quality gate):
- IslandEditPanel: read the island name before getGeneratorData, whose
  null check made Sonar treat the island as nullable.
- IslandEditPanel: null-safe game mode name in three button descriptions.
- canPurchaseGenerator NPE: cherry-picked from #176.

Code smells in StoneGeneratorImportManager: constants for repeated
literals, rename a local that hid a field, extract export error
reporting to cut complexity, make DefaultJSONHandler fields final.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant