From b12e3610b51fc085b4346d0d807612ff967c34bb Mon Sep 17 00:00:00 2001 From: Henry Le Grys Date: Mon, 7 Dec 2020 03:44:03 +0000 Subject: [PATCH] Fix Updater logic for downloading a missing version manifest This codepath was unlikely to be hit since modern manifests always embed the version manifest, but good to have a working fallback... --- .../com/skcraft/launcher/update/Updater.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/launcher/src/main/java/com/skcraft/launcher/update/Updater.java b/launcher/src/main/java/com/skcraft/launcher/update/Updater.java index 6977dba..cf9c322 100644 --- a/launcher/src/main/java/com/skcraft/launcher/update/Updater.java +++ b/launcher/src/main/java/com/skcraft/launcher/update/Updater.java @@ -14,6 +14,8 @@ import com.skcraft.launcher.Instance; import com.skcraft.launcher.Launcher; import com.skcraft.launcher.LauncherException; import com.skcraft.launcher.install.Installer; +import com.skcraft.launcher.model.minecraft.ReleaseList; +import com.skcraft.launcher.model.minecraft.Version; import com.skcraft.launcher.model.minecraft.VersionManifest; import com.skcraft.launcher.model.modpack.Manifest; import com.skcraft.launcher.persistence.Persistence; @@ -108,12 +110,16 @@ public class Updater extends BaseUpdater implements Callable, Progress mapper.writeValue(instance.getVersionPath(), version); return version; } else { - URL url = url(String.format( - launcher.getProperties().getProperty("versionManifestUrl"), - manifest.getGameVersion())); + URL url = url(launcher.getProperties().getProperty("versionManifestUrl")); - return HttpRequest - .get(url) + ReleaseList releases = HttpRequest.get(url) + .execute() + .expectResponseCode(200) + .returnContent() + .asJson(ReleaseList.class); + + Version relVersion = releases.find(manifest.getGameVersion()); + return HttpRequest.get(url(relVersion.getUrl())) .execute() .expectResponseCode(200) .returnContent()