Make Peaceful spawn guard robust during world creation#16
Merged
Conversation
The populator runs while the world is still being created (inside WorldCreator.createWorld), so Bukkit.getWorld(uid) can return null and the previous difficulty check would be bypassed, letting monster spawns crash the chunk system again. - Fall back to the addon's configured difficulty when the live world is not yet registered. - Wrap spawnEntity in a try/catch for IllegalStateException so a failed spawn can never propagate and trigger an unrecoverable chunk system failure during world generation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #15. The smoke test still crashed with the exact same stack trace because the released jar pre-dates that fix — and because the original guard was not robust enough for this code path.
Why #15 alone wasn't sufficient
The populator runs while the world is still being created, inside
WorldCreator.createWorld()(Poseidon.getWorld:167→createWorlds:140). At that point the world is not yet registered with Bukkit, soBukkit.getWorld(worldInfo.getUID())can returnnull, thepeacefulflag evaluates tofalse, and monster spawns proceed — crashing the chunk system again:(seen in https://github.com/BentoBoxWorld/bbox-test-harness/actions/runs/28332381857/job/83932707724)
Fix
Settings.getDifficulty()).spawnEntityin atry/catch (IllegalStateException). This is the real guarantee — a failed spawn for any reason (difficulty restriction, detection mismatch) is caught locally and can never propagate into an unrecoverable chunk-system failure during world generation.No further version bump needed — #15 already set the version to 1.1.1.
🤖 Generated with Claude Code