Fix/legacy modpack null type - #6599
Open
fatelove42 wants to merge 2 commits into
Open
Conversation
Contributor
|
维护者已经开始猜疑有 AI 特征的 PR 了:#6598 不过我先帮作者解释一下:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
修复了由于旧版本 HMCL 或第三方工具导出的整合包配置文件
modpack.cfg中缺失type字段,导致在最新版本 HMCL 中更新整合包时抛出IllegalArgumentException或JsonParseException并中断更新的问题。根本原因
ModpackConfiguration.validate()强制要求type字段不能为null。在解析缺乏"type"键的旧版modpack.cfg时,校验失败导致反序列化抛出异常并落空。CurseInstallTask及其他整合包安装任务在比对提供商类型时没有检查type是否为null。在旧配置中type为null时,!"Curse".equals(null)被计算为true,从而误判并抛出IllegalArgumentException(“Instance is not a CurseForge modpack. Cannot update this instance.”)。主要修改
ModpackConfiguration.validate():移除了ModpackConfiguration.validate()中对type == null的强行抛错限制,允许旧版本整合包配置成功反序列化。CurseInstallTask、ModrinthInstallTask、McbbsModpackLocalInstallTask、McbbsModpackRemoteInstallTask、MultiMCModpackInstallTask、ServerModpackLocalInstallTask、ServerModpackRemoteInstallTask)中增加了config.getType() != null的前置检查。只有当type存在且明确与当前提供商不匹配时才抛出异常拦截;老整合包(type == null)将顺畅放行并在更新完成后自动写回包含type的规范新配置。