Skip to content

Validate lootables refresh-max is not below refresh-min - #14166

Closed
chirag-gamer wants to merge 1 commit into
PaperMC:mainfrom
chirag-gamer:fix/validate-lootable-refresh-range
Closed

Validate lootables refresh-max is not below refresh-min#14166
chirag-gamer wants to merge 1 commit into
PaperMC:mainfrom
chirag-gamer:fix/validate-lootable-refresh-range

Conversation

@chirag-gamer

Copy link
Copy Markdown

lootables.refresh-min and lootables.refresh-max were never checked against each other. With refresh-max below refresh-min, PaperLootableInventoryData#shouldClearLootTable computes RANDOM.nextLong(max - min + 1) with a non-positive bound, which throws IllegalArgumentException: bound must be positive the first time a lootable container is cleared. I verified that throw with a small program (new Random().nextLong(0) throws).

Fixes #14165

Added a @PostProcess validation on the Lootables config part, the same pattern precomputeDespawnDistances uses. It rejects refresh-max < refresh-min with a clear message at config load, so the mistake fails loudly at startup instead of at the first chest.

Compiles against the full server. I didn't add a unit test because this runs through the world config loading path, which needs the Minecraft registries to be present; happy to add one if there's a pattern for it.

@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Aug 8, 2026
@github-project-automation github-project-automation Bot moved this from Awaiting review to Closed in Paper PR Queue Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

Lootable refill crashes when refresh-max is below refresh-min

2 participants