Conversation
|
需要懂其他语言的人完善 i18n |
在BMC4中测试时发现BMC4会判定所有资源包兼容,与原版表现不符,会导致启用/禁用功能失效,故添加警告
HMCLCore/src/main/java/org/jackhuang/hmcl/resourcepack/ResourcepackFile.java
Outdated
Show resolved
Hide resolved
|
我下载了 Translations for Sodium,放在 1.21.9~1.21.11 的资源包文件夹内,启动器会显示「游戏版本元数据缺失」。1.21.8 和 1.21.1 正常。不知道是不是 bug。 |
Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com>
Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com>
确实是,我在修 |
…esourcepack-enhancement
Solved |
# Conflicts: # HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java
There was a problem hiding this comment.
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
CheckUpdatesTaskis still typed againstLocalModFile.ModUpdate, butLocalModFile.ModUpdatewas removed (updates are nowLocalAddonFile.ModUpdate). This will not compile; update thedependentslist type and thecandidate/updatevariables to useLocalAddonFile.ModUpdateconsistently (and drop the unnecessaryLocalModFileimport).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
HMCLCore/src/main/java/org/jackhuang/hmcl/resourcepack/ResourcePackManager.java
Show resolved
Hide resolved
| /// 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(); | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
如果有 json 格式错误那必然会全部失效,游戏内也一样
我读了代码,mc 也是用的 gson 读取,所以我认为没问题
| 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; | ||
| } |
There was a problem hiding this comment.
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.
HMCLCore/src/test/java/org/jackhuang/hmcl/resourcepack/ResourcePackManagerTest.java
Show resolved
Hide resolved
HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalFileManager.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ResourcePackListPage.java
Show resolved
Hide resolved
HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalFileManager.java
Outdated
Show resolved
Hide resolved
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AddonUpdatesPage.java
Outdated
Show resolved
Hide resolved
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ResourcePackListPage.java
Outdated
Show resolved
Hide resolved
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ResourcePackListPage.java
Outdated
Show resolved
Hide resolved
|
|
||
| private void setSelectedEnabled(List<ResourcePackInfoObject> selectedItems, boolean enabled) { | ||
| if (!ConfigHolder.globalConfig().isResourcePackWarningShown()) { | ||
| Controllers.confirmWithCountdown( |
There was a problem hiding this comment.
哪里移除了?这不还是在用 confirmWithCountdown?
具体改动
LocalAddonFile和LocalFileManager<T extends LocalAddonFile>,使更新对于模组以外的东西(如资源包和光影包)也能适用,从而实现了资源包更新(不保留旧版本)