Skip to content

不再用 Version 表示游戏实例#6322

Open
Glavo wants to merge 86 commits into
HMCL-dev:mainfrom
Glavo:instance
Open

不再用 Version 表示游戏实例#6322
Glavo wants to merge 86 commits into
HMCL-dev:mainfrom
Glavo:instance

Conversation

@Glavo

@Glavo Glavo commented Jul 6, 2026

Copy link
Copy Markdown
Member

过去,HMCL 中使用 Version 类表示游戏实例 Json 内容,并且大量使用类似 versionversionId 这样的名字来表示一个实例的 ID。

由于 version 是一个非常常见的概念,这种用法造成了大量的混淆,开发者很容易把实例 ID 和游戏版本等内容混淆。

本 PR 中更新了代码,用 instance 代替 version 来表示一个游戏实例。本 PR 中创建了一个新的类 GameInstanceID,用来表示一个实例的 ID,更清晰的表示它的用途。

Version 类现在被拆分成了以下几个类:

  • GameInstanceManifest:用来表示一个裸的实例 JSON。
  • GameInstanceManifest.Resolved:用来表示经过解析,不再带有 inheritsFrom 的实例 JSON。
  • GameInstancePatch:用来表示 GameInstanceManifestpatches 字段的一项元素。

Glavo added 30 commits July 4, 2026 15:32
…date GameInstanceManifest to use GameInstanceID for jar references
…, GameAssetDownloadTask, GameRepository, HMCLGameLauncher, and Launcher
Glavo added 21 commits July 6, 2026 21:21
@Glavo Glavo marked this pull request as ready for review July 7, 2026 09:52
@Glavo

Glavo commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@Glavo

Glavo commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +135 to +137
@Override
public @Nullable V put(K key, V value) {
throw new UnsupportedOperationException();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Glavo added 2 commits July 7, 2026 20:00
- 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
@Glavo

Glavo commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

@codex review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant