#109 Changes sign storage to be sharded by region#141
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors sign persistence from a single per-world signs.json into per-(dimension, region) shard files (matching Minecraft’s 32×32-chunk region grid) under a server-root-based storage directory, and introduces a one-shot migration from legacy installs while also fixing the world-path resolution issue described in #133.
Changes:
- Introduces
SignRegionKey+SignRegionPartitionerand new region-sharded loader/writer to store signs asr.<regionX>.<regionZ>.jsonper dimension. - Updates server path resolution via
ServerPathProvider#getMarkerStorageRoot(MinecraftServer)and wires it into mod startup/shutdown persistence. - Adds migration logic for legacy
signs.json(load via existing V1/V2/V3 loader chain, write shards, then back up legacy file) plus a comprehensive JUnit test suite for the new persistence behavior.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/tpwalke2/bluemapsignmarkers/BlueMapSignMarkersMod.java | Uses new storage-root API; loads from sharded storage or migrates legacy; saves to sharded storage. |
| src/main/java/com/tpwalke2/bluemapsignmarkers/ServerPathProvider.java | Repurposes interface to provide marker storage root from MinecraftServer. |
| src/main/java/com/tpwalke2/bluemapsignmarkers/common/FileUtils.java | Adds move-to-backup helper used by legacy migration. |
| src/main/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/SignProvider.java | Switches persistence orchestration to region-sharded storage + legacy migration fallback. |
| src/main/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/SignRegionKey.java | Defines (dimension, regionX, regionZ) key and shard file path mapping. |
| src/main/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/SignRegionPartitioner.java | Partitions sign entries into region shards for writing. |
| src/main/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/RegionShardedSignEntryWriter.java | Writes per-region JSON shards and cleans up stale shard files. |
| src/main/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/loaders/RegionShardedSignEntryLoader.java | Walks shard tree and loads all region files into sign entries. |
| src/main/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/LegacySignFileMigrator.java | One-shot migration from legacy single-file storage into region shards + backup. |
| src/test/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/SignRegionKeyTest.java | Tests region math + dimension path splitting for shard layout. |
| src/test/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/SignRegionPartitionerTest.java | Tests partitioning behavior across dimensions and regions. |
| src/test/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/RegionShardedSignEntryWriterTest.java | Verifies writer output, version envelope, and stale shard deletion. |
| src/test/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/RegionShardedSignEntryLoaderTest.java | Verifies loader behavior and writer/loader round-trip across shards. |
| src/test/java/com/tpwalke2/bluemapsignmarkers/core/signs/persistence/LegacySignFileMigratorTest.java | Verifies migration behavior and legacy backup semantics. |
| plans/region-sharded-sign-persistence-plan.md | Documents rationale, design, and migration considerations. |
| plans/codebase-review-2026-07-11.md | Adds broader codebase-review notes (reference material). |
| gradle.properties | Bumps mod_version for the storage layout change. |
| .gitignore | Ignores logs/ directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Region-shards sign persistence into per-(dimension, region) JSON files stored under a per-server root, replacing the single flat signs.json per world, and fixes a related storage-path bug (#133) along the way.
Why
Chunk deletion/regen tools (Chunky, MCA Selector, manual .mca deletion) give no "sign removed" event, so stale signs accumulate forever; fixing that requires cheaply answering "what signs exist in this region," which a single-file, full-scan load can't do.
Region-sharded storage (32×32 chunks, matching Minecraft's own Anvil region size) gives that query a natural home — the actual reconciliation logic is a follow-up issue (#110).
Addresses GitHub issues
Changes
so negative coordinates partition correctly) and dimension-string splitting.
normalizing, getParent()/getFileName() land one level too deep (inside the world save folder instead of beside it).
Testing
the legacy file backed up, not deleted.