Skip to content

Suppress structures in the spawn area too (#116)#118

Merged
tastybento merged 1 commit into
developfrom
fix/structure-spawn-area-116
Jul 9, 2026
Merged

Suppress structures in the spawn area too (#116)#118
tastybento merged 1 commit into
developfrom
fix/structure-spawn-area-116

Conversation

@tastybento

Copy link
Copy Markdown
Member

Problem

Follow-up to #117, closing the other half of #116: a disabled structure could still generate near spawn.

StructureGenerationListener was registered in onEnable(), but BentoBox calls createWorlds() before onEnable(), and creating a world also generates its spawn-area chunks. Those first structures were placed before the listener existed, so they escaped suppression. This matches the reporter finding a trial chamber despite trial_chambers: false, and the debug run where the listener registered ~5 s after Creating CaveBlock world ....

Fix

Register the listener at the start of createWorlds(), before any world is created, so it is active for the initial spawn generation.

That alone isn't sufficient: createWorlds() assigns islandWorld from the return value of createWorld(), so islandWorld is still null while the spawn chunks generate. The async AsyncStructureSpawnEvent handler calling addon.inWorld(world) would then compare against a null world (Util.sameWorldstripName(null) → NPE) and silently fail to cancel.

So both handlers now match on the configured world name via a new isCaveOverworld() helper instead of inWorld(), removing the dependency on the not-yet-assigned world reference.

Testing

  • mvn test — all 78 pass. The listener tests were updated to match on world name (getWorldName() / World#getName()) rather than inWorld().
  • Manual verification on Paper/Purpur 1.21.11 with a freshly deleted world.

Note

Structures already written to region files by a previous run are unaffected — clearing them needs a world reset.

🤖 Generated with Claude Code

The structure listener was registered in onEnable(), but createWorlds()
runs before onEnable() and generating a world also generates its
spawn-area chunks. Those first structures were therefore placed before
the listener existed, so a disabled structure could still appear near
spawn.

Register the listener at the start of createWorlds(), before any world is
created. Because createWorlds() assigns islandWorld from the return value
of createWorld(), the island-world reference is still null while the
spawn chunks generate, so inWorld() would compare against a null world
and throw. Match on the configured world name instead via a new
isCaveOverworld() helper, used by both handlers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GBGsNFUshypm5Sj8KQsEa
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@tastybento tastybento merged commit eb8c2a9 into develop Jul 9, 2026
3 checks passed
@tastybento tastybento deleted the fix/structure-spawn-area-116 branch July 9, 2026 14:36
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