Commit f254f04
fix: refresh initialCount in tidyUp to close zero-scan/regular-scan race
When a player runs /level shortly after island creation and the zero scan
is parked on awaitPendingZeros for newly-generated chunks (typical when
/po create teleports the player and that fires isNewChunk events inside
the island bounds), the regular scan's constructor reads DB initialCount
before the zero scan's setInitialIslandCount has fired, snapshotting
initialCount=0 into results. By the time the regular scan's tidyUp runs,
the zero scan has finished, persisted is populated, and reconcile
returns delta=0 — so results.initialCount stays at 0 and the level math
treats every block as player-placed (level = totalPoints / level_cost).
Refresh results.initialCount from the DB after reconcile so the live
computation picks up:
(a) a zero scan's setInitialIslandCount that landed between our
constructor and now,
(b) any reconcile delta this scan just folded in.
This produces level=0 on a fresh island regardless of whether the
regular scan or the zero scan wins the race to tidyUp.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 22f20bb commit f254f04
2 files changed
Lines changed: 41 additions & 5 deletions
File tree
- src
- main/java/world/bentobox/level/calculators
- test/java/world/bentobox/level/calculators
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
868 | | - | |
869 | | - | |
| 868 | + | |
870 | 869 | | |
871 | 870 | | |
872 | | - | |
873 | | - | |
874 | | - | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
875 | 886 | | |
876 | 887 | | |
877 | 888 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
235 | 260 | | |
236 | 261 | | |
237 | 262 | | |
| |||
0 commit comments