Skip to content

feat: 拖拽版本 json 安装实例#5730

Open
CiiLu wants to merge 2 commits intoHMCL-dev:mainfrom
CiiLu:json
Open

feat: 拖拽版本 json 安装实例#5730
CiiLu wants to merge 2 commits intoHMCL-dev:mainfrom
CiiLu:json

Conversation

@CiiLu
Copy link
Contributor

@CiiLu CiiLu commented Mar 7, 2026

resolves #5459

Copy link
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

Adds support for creating/installing a game instance by dragging a Minecraft version-manifest-style JSON into the launcher, addressing feature request #5459 (install unlisted/ancient/third-party versions without manual folder setup).

Changes:

  • Add i18n strings for “malformed instance JSON”.
  • Add Versions.installFromJson(Profile, Path) to parse a version JSON, write it into <gameDir>/versions/<id>/<id>.json, and trigger game jar download.
  • Extend drag-and-drop handlers (Root page + Game list page) to accept JSON files and invoke the new installer.

Reviewed changes

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

Show a summary per file
File Description
HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties Adds zh_CN error message for invalid instance JSON.
HMCL/src/main/resources/assets/lang/I18N_zh.properties Adds zh_TW error message for invalid instance JSON.
HMCL/src/main/resources/assets/lang/I18N.properties Adds English error message for invalid instance JSON.
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Implements JSON-based instance installation + download flow.
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/RootPage.java Allows dragging .json into main page to trigger install.
HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java Allows dragging files into game list page to trigger install.

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

FXUtils.applyDragListener(gameListPage, ModpackHelper::isFileModpackByExtension, modpacks -> {
Path modpack = modpacks.get(0);
Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(Profiles.getSelectedProfile(), modpack), i18n("install.modpack"));
FXUtils.applyDragListener(gameListPage, file -> ModpackHelper.isFileModpackByExtension(file) || "json".equalsIgnoreCase(FileUtils.getNameWithoutExtension(file)), files -> {
Comment on lines +177 to +179
profile.getRepository().refreshVersions();
profile.setSelectedVersion(result);
handler.resolve();
});
Task.runAsync(() -> {
var dir = profile.getGameDir().resolve("versions");
var versionDir = Files.createDirectory(dir.resolve(result));
install.new_game.current_game_version=Current Instance Version
install.new_game.installation=Instance Installation
install.new_game.malformed=Invalid name.
install.new_game.malformed_json=Invalid Minecraft instance JSON file。
@CiiLu CiiLu changed the title Support installing instance from version manifest json feat: 拖拽版本 json 安装实例 Mar 13, 2026
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.

2 participants