Skip to content

[Feature] [Bugfix] 资源包有关优化与修复#4980

Open
Calboot wants to merge 104 commits intoHMCL-dev:mainfrom
Calboot:resourcepack-enhancement
Open

[Feature] [Bugfix] 资源包有关优化与修复#4980
Calboot wants to merge 104 commits intoHMCL-dev:mainfrom
Calboot:resourcepack-enhancement

Conversation

@Calboot
Copy link
Contributor

@Calboot Calboot commented Dec 14, 2025

  • 资源包管理界面边框样式修复
  • 修复资源包依赖模组下载错误的问题
  • 资源包启用/禁用功能
  • 资源包详细信息界面
  • 与模组管理界面同步
  • 更新资源包

具体改动

@Calboot
Copy link
Contributor Author

Calboot commented Dec 14, 2025

需要懂其他语言的人完善 i18n

@Calboot Calboot changed the title [Enhancement] 资源包有关优化与修复 [Enhancement] [Bugfix] 资源包有关优化与修复 Dec 14, 2025
Copy link
Contributor

@3gf8jv4dv 3gf8jv4dv left a comment

Choose a reason for hiding this comment

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

我在 CF 和 MR 分别下载了好几个资源包,结果都显示「游戏版本元数据缺失」。如果真的要为这个显示警告的话,可能很多人都会迷惑。

可能是我搞错了,我还在弄清楚这一块。

@3gf8jv4dv
Copy link
Contributor

我下载了 Translations for Sodium,放在 1.21.9~1.21.11 的资源包文件夹内,启动器会显示「游戏版本元数据缺失」。1.21.8 和 1.21.1 正常。不知道是不是 bug。

Calboot and others added 2 commits December 17, 2025 21:28
Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com>
Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com>
@Calboot
Copy link
Contributor Author

Calboot commented Dec 17, 2025

我下载了 Translations for Sodium,放在 1.21.9~1.21.11 的资源包文件夹内,启动器会显示「游戏版本元数据缺失」。1.21.8 和 1.21.1 正常。不知道是不是 bug。

确实是,我在修

@Calboot
Copy link
Contributor Author

Calboot commented Dec 18, 2025

我下载了 Translations for Sodium,放在 1.21.9~1.21.11 的资源包文件夹内,启动器会显示「游戏版本元数据缺失」。1.21.8 和 1.21.1 正常。不知道是不是 bug。

Solved

@Calboot Calboot marked this pull request as ready for review December 18, 2025 14:53
@Calboot Calboot requested a review from Glavo January 30, 2026 11:24
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

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

Comments suppressed due to low confidence (1)

HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/CheckUpdatesTask.java:42

  • CheckUpdatesTask is still typed against LocalModFile.ModUpdate, but LocalModFile.ModUpdate was removed (updates are now LocalAddonFile.ModUpdate). This will not compile; update the dependents list type and the candidate/update variables to use LocalAddonFile.ModUpdate consistently (and drop the unnecessary LocalModFile import).

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

Comment on lines 535 to 554
/// Turns `List.of("a", "b", "c")` into `["a", "b", "c"]`
@Contract(pure = true)
public static String serializeStringList(List<String> list) {
if (list == null) return "[]";
try {
return JsonUtils.UGLY_GSON.toJson(list.stream().filter(Objects::nonNull).toList(), JsonUtils.listTypeOf(String.class).getType());
} catch (Exception e) {
return "[]";
}
}

/// Turns `["a", "b", "c"]` into `List.of("a", "b", "c")`
@Contract(pure = true)
public static List<String> deserializeStringList(String list) {
if (list == null || list.isBlank()) return List.of();
try {
return JsonUtils.fromNonNullJson(list, JsonUtils.listTypeOf(String.class));
} catch (Exception e) {
return List.of();
}
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

serializeStringList/deserializeStringList swallow all exceptions and return an empty list/[]. Because these helpers are used to persist options.txt values (e.g., resourcePacks), a transient/format error will cause the caller to overwrite the original value with an empty list, potentially losing the user’s enabled-pack configuration. Consider narrowing the catch to JSON parse exceptions and either (1) rethrow/return a failure signal so callers can avoid saving, or (2) at least log and return the original input unmodified when parsing fails.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

如果有 json 格式错误那必然会全部失效,游戏内也一样

我读了代码,mc 也是用的 gson 读取,所以我认为没问题

Comment on lines 391 to 399
Predicate<@Nullable String> predicate;
if (queryString.startsWith("regex:")) {
try {
Pattern pattern = Pattern.compile(queryString.substring("regex:".length()));
predicate = s -> s != null && pattern.matcher(s).find();
} catch (Throwable e) {
LOG.warning("Illegal regular expression", e);
return;
}
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

In search(), when the query starts with regex:, the code clears listView.getItems() before compiling the pattern. If Pattern.compile(...) throws, the method returns early and the list stays empty until the user manually closes the search bar. Compile/validate the regex before clearing, or restore the original items (or show an in-UI validation message) when the regex is invalid.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CC @Glavo
这个是历史遗留问题吗

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

Copilot reviewed 46 out of 46 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (4)

HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modinfo/PackMcMeta.java:1

  • The sentinel value for UNSPECIFIED has changed from (0, 0) to (-1, -1). This is a breaking change that could affect existing code comparing against the old sentinel values. Consider documenting this change or providing a migration path.
    HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modinfo/PackMcMeta.java:1
  • The isUnspecified() check should ensure both values are negative to match the UNSPECIFIED constant (-1, -1), not just one or the other. Use AND (&&) instead of OR (||) to properly identify the unspecified state.
    HMCLCore/src/main/java/org/jackhuang/hmcl/util/StringUtils.java:1
  • Using triple-slash (///) for comments is unconventional in Java. Standard JavaDoc comments should use /** */ for documentation, or // for single-line comments.
    HMCLCore/src/main/java/org/jackhuang/hmcl/util/StringUtils.java:1
  • Using triple-slash (///) for comments is unconventional in Java. Standard JavaDoc comments should use /** */ for documentation, or // for single-line comments.

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


private void setSelectedEnabled(List<ResourcePackInfoObject> selectedItems, boolean enabled) {
if (!ConfigHolder.globalConfig().isResourcePackWarningShown()) {
Controllers.confirmWithCountdown(
Copy link
Member

Choose a reason for hiding this comment

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

哪里移除了?这不还是在用 confirmWithCountdown

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

Labels

None yet

Projects

None yet

5 participants

Comments