Use version manifest v2, fix ComparableVersion and try to ensure that dependencies are downloaded when launching an instance

This commit is contained in:
JFronny 2021-11-25 17:55:50 +01:00
parent e52c0277b6
commit b6d9066c07
No known key found for this signature in database
GPG Key ID: BEC5ACBBD4EE17E5
7 changed files with 20 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package io.gitlab.jfronny.inceptum.cli;
import io.gitlab.jfronny.inceptum.Inceptum;
import io.gitlab.jfronny.inceptum.install.Steps;
import io.gitlab.jfronny.inceptum.model.inceptum.InstanceMeta;
import io.gitlab.jfronny.inceptum.util.ClientLauncher;
import io.gitlab.jfronny.inceptum.util.ProcessUtils;
@ -72,6 +73,11 @@ public class LaunchCommand extends Command {
instance.gameArgsCustom = instance.gameArgsCustom == null ? new ArrayList<>() : new ArrayList<>(instance.gameArgsCustom);
instance.gameArgsCustom.addAll(args.after(pArgIndex));
}
try {
Steps.reDownload(instanceDir);
} catch (IOException e) {
e.printStackTrace();
}
if (server) ServerLauncher.launch(instanceDir, instance, restart);
else {
AccountManager.loadAccounts();

View File

@ -43,8 +43,10 @@ public class Steps {
if (Files.exists(instance.resolve("inceptum.setup.lock"))) return;
if (Files.exists(instance.resolve("inceptum.lock"))) return;
InstanceMeta im = Utils.loadObject(instance.resolve("instance.json"), InstanceMeta.class);
boolean found = false;
for (VersionsListInfo version : McApi.getVersions().versions) {
if (version.id.equals(im.getMinecraftVersion())) {
found = true;
VersionInfo vi = McApi.getVersionInfo(version);
if (im.isFabric()) FabricMetaApi.addFabric(vi, im.getLoaderVersion(), FabricMetaApi.FabricVersionInfoType.Both);
LoaderInfo li = im.isFabric()
@ -56,5 +58,6 @@ public class Steps {
}
}
}
if (!found) throw new IOException("Could not identify minecraft version " + im.getMinecraftVersion());
}
}

View File

@ -7,7 +7,6 @@ public class VersionInfo extends VersionsListInfo {
public Arguments arguments;
public AssetIndex assetIndex;
public String assets;
public int complianceLevel;
public Downloads downloads;
public JavaVersion javaVersion;
public List<Library> libraries;

View File

@ -8,4 +8,6 @@ public class VersionsListInfo {
public String url;
public Date time;
public Date releaseTime;
public String sha1;
public Integer complianceLevel;
}

View File

@ -16,14 +16,14 @@ import static io.gitlab.jfronny.inceptum.util.Utils.downloadObject;
public class McApi {
public static VersionsList getVersions() {
try {
return downloadObject("https://launchermeta.mojang.com/mc/game/version_manifest.json", VersionsList.class);
return downloadObject("https://launchermeta.mojang.com/mc/game/version_manifest_v2.json", VersionsList.class);
} catch (IOException e) {
throw new RuntimeException("Could not load version manifest", e);
}
}
public static VersionInfo getVersionInfo(VersionsListInfo listInfo) throws IOException {
return downloadObject(listInfo.url, VersionInfo.class);
return downloadObject(listInfo.url, listInfo.sha1, VersionInfo.class);
}
public static AssetIndex getAssetIndex(VersionInfo info) throws IOException {

View File

@ -4,6 +4,7 @@ import imgui.ImGui;
import imgui.flag.ImGuiTableFlags;
import io.gitlab.jfronny.inceptum.Inceptum;
import io.gitlab.jfronny.inceptum.InceptumGui;
import io.gitlab.jfronny.inceptum.install.Steps;
import io.gitlab.jfronny.inceptum.model.inceptum.InstanceMeta;
import io.gitlab.jfronny.inceptum.util.ClientLauncher;
import io.gitlab.jfronny.inceptum.util.ProcessUtils;
@ -50,6 +51,11 @@ public class InstanceView {
}
if (disabled) ImGui.beginDisabled();
if (ImGui.button(path.getFileName().toString())) {
try {
Steps.reDownload(path);
} catch (IOException e) {
e.printStackTrace();
}
ClientLauncher.launch(path, instance);
}
ImGui.tableNextColumn();

View File

@ -6,7 +6,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
public ComparableVersion(String string) {
this.string = string;
String[] split = string.split("[.+]+");
String[] split = string.split("[.+-]+");
this.numbers = new int[split.length];
for (int i = 0; i < split.length; i++) {
try {