-
Notifications
You must be signed in to change notification settings - Fork 922
Fix/兼容从hmcl旧版本安装的整合包升级 #6599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix/兼容从hmcl旧版本安装的整合包升级 #6599
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| @Immutable | ||
| public final class ModpackConfiguration<T> implements Validation { | ||
|
|
@@ -36,7 +37,7 @@ public static <T> TypeToken<ModpackConfiguration<T>> typeOf(Class<T> clazz) { | |
| } | ||
|
|
||
| private final T manifest; | ||
| private final String type; | ||
| private final @Nullable String type; | ||
| private final String name; | ||
| private final String version; | ||
| private final List<FileInformation> overrides; | ||
|
|
@@ -45,7 +46,7 @@ public ModpackConfiguration() { | |
| this(null, null, "", null, Collections.emptyList()); | ||
| } | ||
|
|
||
| public ModpackConfiguration(T manifest, String type, String name, String version, List<FileInformation> overrides) { | ||
| public ModpackConfiguration(T manifest, @Nullable String type, String name, String version, List<FileInformation> overrides) { | ||
| this.manifest = manifest; | ||
| this.type = type; | ||
| this.name = name; | ||
|
|
@@ -57,8 +58,41 @@ public T getManifest() { | |
| return manifest; | ||
| } | ||
|
|
||
| @Nullable | ||
| public String getType() { | ||
| return type; | ||
| if (type != null) { | ||
| return type; | ||
| } | ||
| if (manifest instanceof ModpackManifest modpackManifest) { | ||
| return modpackManifest.getProvider().getName(); | ||
| } | ||
| if (manifest instanceof Modpack modpack) { | ||
| if (modpack.getManifest() != null) { | ||
| return modpack.getManifest().getProvider().getName(); | ||
| } | ||
| return "HMCL"; | ||
| } | ||
| if (manifest instanceof Map<?, ?> map) { | ||
| if (map.containsKey("instanceType") || map.containsKey("components") || map.containsKey("mmcPack")) { | ||
| return "MultiMC"; | ||
| } | ||
| if (map.containsKey("formatVersion") && map.containsKey("game")) { | ||
| return "Modrinth"; | ||
| } | ||
| if (map.containsKey("files") && map.containsKey("minecraft")) { | ||
| return "Curse"; | ||
| } | ||
| if (map.containsKey("fileApi") && !map.containsKey("manifestType")) { | ||
| return "Server"; | ||
| } | ||
| if (map.containsKey("addons") || map.containsKey("manifestType")) { | ||
| return "Mcbbs"; | ||
| } | ||
| if (map.containsKey("manifest") || map.containsKey("gameVersion") || map.containsKey("description")) { | ||
| return "HMCL"; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| public String getName() { | ||
|
|
@@ -90,8 +124,6 @@ public List<FileInformation> getOverrides() { | |
| public void validate() throws JsonParseException { | ||
| if (manifest == null) | ||
| throw new JsonParseException("MinecraftInstanceConfiguration missing `manifest`"); | ||
| if (type == null) | ||
| throw new JsonParseException("MinecraftInstanceConfiguration missing `type`"); | ||
| } | ||
|
Comment on lines
124
to
127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an existing Useful? React with 👍 / 👎. |
||
|
|
||
| @Immutable | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.