不再用 Version 表示游戏实例#6322
Conversation
…bleSequencedMap class
…r improved configuration
…est for enhanced structure
…class for game instance management
…ve list handling in GameInstanceManifest
…aultGameRepository2 for thread safety
…ling for improved clarity
…date GameInstanceManifest to use GameInstanceID for jar references
…est handling and patch preservation
…meInstancePatch structure
…ameInstanceManifest for patch serialization
…stanceManifest and GameInstancePatch
…nownFields handling in GameInstancePatch
…stanceManifest and GameInstancePatch
…date related references
…tance renaming support
…ust related types
…update references
…ask and GameAssetIndexDownloadTask
…, GameAssetDownloadTask, GameRepository, HMCLGameLauncher, and Launcher
…ask for consistency
…r instance retrieval
… GameInstanceManifest
…gging in GameInstanceManifest
…ownloads and logging
…mplement standard map methods
|
/gemini review |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 458dea1a99
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var map = new LinkedHashMap<DownloadType, DownloadInfo>(); | ||
| for (Map.Entry<String, JsonElement> downloadEntry : obj.entrySet()) { | ||
| try { | ||
| DownloadType type = DownloadType.valueOf(downloadEntry.getKey()); |
There was a problem hiding this comment.
Parse Mojang download keys instead of dropping them
When parsing official version JSON, the downloads object uses lower-case keys such as client and client_mappings, but DownloadType.valueOf(...) only accepts enum names like CLIENT_MAPPINGS. Because the IllegalArgumentException is swallowed here, those entries are silently omitted; for example the Forge/NeoForge DOWNLOAD_MOJMAPS patch later reads getDownloads().get(DownloadType.CLIENT_MAPPINGS) and fails with client_mappings download info not found for modern installs that need Mojang mappings. Use the existing lower-case enum adapter or normalize the key before lookup.
Useful? React with 👍 / 👎.
| @Override | ||
| public @Nullable V put(K key, V value) { | ||
| throw new UnsupportedOperationException(); |
There was a problem hiding this comment.
Return unmodifiable views from the immutable map
LinkedHashMap.keySet() is a write-through view, so callers can mutate an ImmutableSequencedMap via map.keySet().remove(...) even though this class and the manifest fields advertise unmodifiable collections. This can corrupt parsed manifest state through accessors like getDownloads().keySet(); wrap the key/values/entry views or expose copies so the map is actually immutable.
Useful? React with 👍 / 👎.
- normalize enum names with `Locale.ROOT` when building lowercase lookup maps - avoid locale-dependent casing differences that can break enum deserialization on non-English systems
|
@codex review |
过去,HMCL 中使用
Version类表示游戏实例 Json 内容,并且大量使用类似version、versionId这样的名字来表示一个实例的 ID。由于 version 是一个非常常见的概念,这种用法造成了大量的混淆,开发者很容易把实例 ID 和游戏版本等内容混淆。
本 PR 中更新了代码,用 instance 代替 version 来表示一个游戏实例。本 PR 中创建了一个新的类
GameInstanceID,用来表示一个实例的 ID,更清晰的表示它的用途。Version类现在被拆分成了以下几个类:GameInstanceManifest:用来表示一个裸的实例 JSON。GameInstanceManifest.Resolved:用来表示经过解析,不再带有inheritsFrom的实例 JSON。GameInstancePatch:用来表示GameInstanceManifest中patches字段的一项元素。