Skip to content

feat: 支持重置实例#5418

Open
CiiLu wants to merge 13 commits intoHMCL-dev:mainfrom
CiiLu:language
Open

feat: 支持重置实例#5418
CiiLu wants to merge 13 commits intoHMCL-dev:mainfrom
CiiLu:language

Conversation

@CiiLu
Copy link
Copy Markdown
Contributor

@CiiLu CiiLu commented Feb 4, 2026

我感觉提供一个这样的功能是很方便的。

混用启动器或者复制 Forge 游戏文件时没有同时复制 libraries 文件夹等行为会导致游戏无法启动,这种一般需要手动重新安装同版本游戏,前者还需要迁移存档等文件。

在启动器里提供一个基本没有副作用的快捷操作很方便,且 PCLCE、BakaXL等启动器也提供了类似的操作。

提供重置实例功能同时可以解决外部安装实例的自动安装无法操作的问题。

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a "Reset Instance" feature to the HMCL Minecraft launcher, allowing users to reinstall a game instance while preserving save files, mods, and other game data. This feature helps resolve issues caused by missing or corrupted game files (e.g., when libraries folder is not copied during instance migration), providing a convenient recovery option similar to features found in other launchers like PCLCE and BakaXL.

Changes:

  • Added getLibraries() method to LibraryAnalyzer to retrieve all detected library types for an instance
  • Implemented resetVersion() functionality that rebuilds an instance by reinstalling all detected libraries while preserving user data
  • Added UI integration with confirmation dialog and menu item in the instance management menu

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
HMCLCore/src/main/java/org/jackhuang/hmcl/download/LibraryAnalyzer.java Added getLibraries() method to return set of detected LibraryType values
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Implemented resetVersion() method that analyzes and rebuilds instance libraries
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java Added resetInstance() UI handler with confirmation dialog and menu integration
HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties Added Simplified Chinese translations for reset feature
HMCL/src/main/resources/assets/lang/I18N_zh.properties Added Traditional Chinese translations for reset feature
HMCL/src/main/resources/assets/lang/I18N.properties Added English translations for reset feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread HMCL/src/main/resources/assets/lang/I18N.properties Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java
Comment thread HMCL/src/main/resources/assets/lang/I18N.properties Outdated
CiiLu and others added 3 commits April 17, 2026 22:27
@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 18, 2026

@codex review

Copy link
Copy Markdown

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

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: 42e2df1400

ℹ️ 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".

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Outdated
@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 23, 2026

@codex review

@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 23, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a 'Reset Instance' feature, allowing users to reinstall the game core while preserving personal data such as worlds and mods. The implementation includes UI updates to the version management page, new localization strings, and the core logic for rebuilding the game instance. A review comment suggests refining the exception handling in the resetVersion method, as the current catch block is too broad and may mask unexpected runtime errors.

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java
Copy link
Copy Markdown

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

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: ca4a4cf742

ℹ️ 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".

Comment on lines +273 to +274
Controllers.taskDialog(builder.buildAsync()
.thenRunAsync(repository::refreshVersions)
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 Avoid deleting instance directory on reset failure

Calling builder.buildAsync() here reuses DefaultGameBuilder, whose failure handler removes the target version directory (HMCLCore/src/main/java/org/jackhuang/hmcl/download/DefaultGameBuilder.java:63-66). During reset, that target is the existing instance ID, so any download/install failure can delete the whole instance folder (including saves/mods for VERSION_FOLDER instances), while the rollback only rewrites the JSON and cannot restore deleted data. This contradicts the reset guarantee that user data is preserved and makes transient network failures destructive.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@CiiLu CiiLu marked this pull request as draft April 23, 2026 14:22
@CiiLu CiiLu marked this pull request as ready for review April 23, 2026 14:45
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.

4 participants