feat(pack-meta): add ForceLoadMeta and PackMetaReader - #24
Closed
Caedis wants to merge 8 commits into
Closed
Conversation
Leaf parser for the txloader block in pack.mcmeta. Supports directory and zip resource packs; returns empty Optional for missing, absent-section, or malformed inputs. Also wires JUnit 5 (test-only): gtnhconvention does not auto- provide it, matching the pattern used by other GTNH projects.
Change parse() to accept Reader instead of InputStream. Caller now owns the Reader lifecycle and wraps it in try-with-resources, while parse() only calls fromJson() without closing. Prevents double-close that occurs when both read() and parse() wrap the stream. Add tests: zip pack with no pack.mcmeta entry, and Priority.fromString case-insensitivity with null/unknown defaults.
Persists pack filename -> first-load timestamp in a JSON map so a pack is force-enabled only once. Returns an empty, usable state on missing or corrupt files.
Inserts pack filenames into the resourcePacks list of options.txt without disturbing other settings. TOP appends (highest priority), BOTTOM prepends; skips duplicates and creates the line/file if absent.
Scans resourcepacks/ on client startup, enables newly force-loaded packs once via OptionsEditor, and records them in forceloaded.json. Wired into the client path of TXLoaderCore.injectData.
Add a Force-loading resource packs section covering the txloader block (forceLoad, priority) and the once-per-pack behavior.
OptionsEditor.enable now returns success; the handler records and saves state only for packs actually written, so a failed write no longer permanently marks a pack force-loaded without enabling it (it retries next boot). Also preserve input order for multiple bottom-priority packs and warn on an unparseable resourcePacks line.
Member
Author
|
No longer needed with GTNewHorizons/GuideNH#33 |
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.
Packs in resourcepacks/ can opt into auto-enabling on first boot via a txloader block in pack.mcmeta (forceLoad + priority top/bottom).
Enabled once, recorded in config/txloader/forceloaded.json. Player can then disable it permanently.
Edits options.txt before it is loaded
Verified in a real client.
Mainly going to be used for the GuideNH guides