fix: reconcile the phase index with the phases folder on load#541
Merged
Conversation
The 1.26.0 phase index shipped as a preset: upgrading servers got the stock phases_index.yml, which references the current jar's file names. Servers with older or custom phase layouts silently lost every phase whose file name differed, never received Sulfur Caves (phase files are only copied on fresh installs), and the admin phases GUI showed the preset instead of the server's reality. The index is now reconciled with the phases folder on every load - the folder is the source of truth for which phases exist: - An entry whose file and section exist on disk keeps its place. - An entry whose file is missing is re-pointed at a folder file holding a phase with the same name (follows shipped file renames), failing that its file is restored from the addon jar (recovers phases added by an upgrade), failing that it is removed. - Folder files not in the index are added. Numeric section keys give a position and length from the legacy start-block layout; non-numeric keys - now fully supported for custom phases, chests pair by file name so they work too - go to the end with the default length for the admin to arrange in the GUI. - When repair was needed, or the index was freshly copied over an existing folder, lengths are refreshed from the gaps between the files' legacy keys, preserving the layout the server actually ran. The admin phases GUI also gains shift-left-click to set a phase's length via a chat prompt that shows the current value. The first such edit writes adminLengths: true to the index, which permanently stops reconciliation from recomputing lengths, so admin values survive later file additions or renames. GUI polish from feedback: phase icons fall back to the phase's first block instead of stone, the how-to-use book wraps onto four lines, and the lore lines are shortened for small screens. Verified end-to-end on a real 26.2 server with a recreated legacy phases folder plus the stock index: all renames re-pointed, Sulfur Caves restored, lengths matched the server's true layout, and a second boot reconciled nothing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013C4BPNygFKjoQenDwTyMNY
- Replace the Bukkit conversation API (deprecated for removal in Paper) with a direct AsyncChatEvent listener for the phase length prompt. Same behaviour: prompt shows the current length, whole numbers above zero apply, invalid input re-prompts, the cancel word or a 60 second timeout keeps the length. Input is applied on the main thread. - Cut cognitive complexity: loadPhases delegates to setUpNewFolder and loadUsingIndex; scanPhaseFolder delegates per file and per section; reconcileIndex is decomposed into reconcileEntry, matchOnDisk, addKeyedDiscoveries, addUnkeyedDiscoveries, and refreshLengthsFromFolder around a small Reconciliation state object. No behaviour change - all 552 tests pass unchanged. - Use static imports for Mockito times in tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013C4BPNygFKjoQenDwTyMNY
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013C4BPNygFKjoQenDwTyMNY
|
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.



Problem
The 1.26.0 phase index shipped as a preset. Upgrading servers received the stock
phases_index.yml, which references the current jar's file names — but theirphases/folders hold older or customized layouts. Community feedback showed the fallout:Fix: reconcile the index with the folder on every load
The folder is the source of truth for which phases exist; the index owns order and enabled state:
11000_deep_dark→10500_deep_dark); failing that, its file is restored from the addon jar (recovers phases added by upgrades, e.g. Sulfur Caves); failing that, the entry is removed with a warning.Also in this PR
/oba phases, via a chat prompt showing the current value (whole numbers > 0,cancelkeeps it). The first edit writesadminLengths: trueto the index, permanently stopping reconciliation from recomputing lengths, so admin values survive later file additions/renames.name/blocks/fixedBlocks/mobs) to be picked up.phases_index.ymlheader documents the new behavior.Testing
🤖 Generated with Claude Code
https://claude.ai/code/session_013C4BPNygFKjoQenDwTyMNY