Skip to content

fix: ignore initialCount in donations-only mode (#430)#433

Merged
tastybento merged 3 commits into
developfrom
fix/430-donations-only-ignore-initial-count
May 12, 2026
Merged

fix: ignore initialCount in donations-only mode (#430)#433
tastybento merged 3 commits into
developfrom
fix/430-donations-only-ignore-initial-count

Conversation

@tastybento
Copy link
Copy Markdown
Member

Follow-up to #432.

Problem

When an admin enables donations-only: true mid-game on a server with existing islands, the level formula goes wildly negative.

Each island already has an initialCount recorded from the one-off starter-island scan that ran when the island was created (under `zero-new-island-levels: true`). The formula subtracts that count from raw points:

```java
long modifiedPoints = rawPoints - initialCount;
```

Under donations-only, `rawPoints` is just the donated total (often 0 to a few thousand), but `initialCount` was the full block count of the starter island (millions of points worth). `modifiedPoints` becomes hugely negative and so does the resulting level.

Fix

Ignore `initialCount` whenever `donations-only` is enabled:

  • `IslandLevelCalculator.calculateLevel(rawPoints)` — no longer subtracts `initialCount`
  • The `pointsFromCurrentLevel` binary search in `tidyUp()` — no longer floors `lo` at `initialCount`
  • The diagnostic report — no longer prints the "Initial island count" line (would be misleading, since it isn't applied to the level math in this mode)

The flag combines cleanly with `zero-new-island-levels`: `zero-new-island-levels && !donations-only` is the new gate.

Test plan

  • `mvn test` — 217/217 pass
  • In-game: enable `donations-only: true` on a server with an existing island that has a non-zero `initialCount`; `/island level` reports a sensible non-negative level based on donated blocks only
  • In-game: disable `donations-only` again; existing scan-based level calc still subtracts `initialCount` as before

🤖 Generated with Claude Code

tastybento and others added 3 commits May 12, 2026 07:17
When an admin enables donations-only mid-game, existing islands already
have an `initialCount` recorded from the original starter-island scan.
The level formula subtracts `initialCount` from raw points when
`zero-new-island-levels` is on — but under donations-only, raw points
are just the donated total, which is typically much smaller than the
recorded initial count. The result was a huge negative `modifiedPoints`
and a wildly negative level.

Ignore `initialCount` (treat as 0) whenever donations-only is enabled:
- `calculateLevel(rawPoints)` no longer subtracts it
- the `pointsFromCurrentLevel` binary search no longer floors at it
- the report no longer prints it (would be misleading, since it isn't
  applied to the level math)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous short-circuit in scanIsland skipped every scan when
donations-only was enabled — including the zero-island scan that fires
on IslandCreatedEvent / IslandResettedEvent. That meant new islands
created during a donations-only window got initialCount = 0, so if an
admin later disabled donations-only the player's entire current block
total would count toward their level (no handicap subtracted).

Restrict the short-circuit to non-zero-island scans. The zero-island
scan still runs and records the real handicap into initialCount; it is
just ignored by calculateLevel while donations-only is on (per the
existing fix in this PR). When donations-only is later disabled, the
stored initialCount is correctly subtracted by calculateLevel as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The viewer button at the bottom of the top-ten panel rendered with a
"Click to view" tooltip and opened the details panel on click. That
panel breaks down scanned blocks, which is meaningless in donations-only
mode (and /island detail is not registered there either).

Add a donations-only check to the VIEW action filter so it's removed
from activeActions for that button when donations-only is enabled.
Filtering it out also drops the "Click to view" tooltip — no template
or locale change needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@tastybento tastybento merged commit 2f4703b into develop May 12, 2026
3 checks passed
@tastybento tastybento deleted the fix/430-donations-only-ignore-initial-count branch May 12, 2026 14:35
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