From 02d7b831f265b07243738f0fdefa903e3e215fa1 Mon Sep 17 00:00:00 2001 From: Ryan Dowling Date: Sat, 23 Jul 2022 18:11:36 +1000 Subject: [PATCH] fix: issue with main Forge library not downloading correctly from our CDN --- CHANGELOG.md | 1 + .../com/atlauncher/data/minecraft/LibraryTypeAdapter.java | 4 ++++ .../minecraft/loaders/forge/ForgeLibraryTypeAdapter.java | 7 +++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27865979..ba328a59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This changelog only contains the changes that are unreleased. For changes for in - Add --debug-level option back in - Noisy logs around images for instance/server cards - Some incorrect colours on light themes +- Issue with main Forge library not downloading correctly from our CDN ### Misc - Remove headless dependency from debian package diff --git a/src/main/java/com/atlauncher/data/minecraft/LibraryTypeAdapter.java b/src/main/java/com/atlauncher/data/minecraft/LibraryTypeAdapter.java index 1c980b65..d9b29b4c 100644 --- a/src/main/java/com/atlauncher/data/minecraft/LibraryTypeAdapter.java +++ b/src/main/java/com/atlauncher/data/minecraft/LibraryTypeAdapter.java @@ -39,6 +39,10 @@ public class LibraryTypeAdapter implements JsonDeserializer { library = new Gson().fromJson(object, ForgeLibrary.class); } else { library = new Gson().fromJson(object, Library.class); + + if (library.name.contains("forge") && library.downloads.artifact.url.endsWith("-launcher.jar")) { + library.downloads.artifact.url = library.downloads.artifact.url.replace("-launcher.jar", ".jar"); + } } return library; diff --git a/src/main/java/com/atlauncher/data/minecraft/loaders/forge/ForgeLibraryTypeAdapter.java b/src/main/java/com/atlauncher/data/minecraft/loaders/forge/ForgeLibraryTypeAdapter.java index 868ee794..067cd886 100644 --- a/src/main/java/com/atlauncher/data/minecraft/loaders/forge/ForgeLibraryTypeAdapter.java +++ b/src/main/java/com/atlauncher/data/minecraft/loaders/forge/ForgeLibraryTypeAdapter.java @@ -57,10 +57,9 @@ public class ForgeLibraryTypeAdapter implements JsonDeserializer { library.downloads = new Gson().fromJson(object.get("downloads").getAsJsonObject(), Downloads.class); if (library.downloads.artifact.url.isEmpty()) { - // forge installer provides this out the zip, but when the file is removed from - // shared libraries, we need to change the url to grab the launcher jar (same) - library.downloads.artifact.url = Constants.FORGE_MAVEN_BASE - + library.downloads.artifact.path.replace(".jar", "-launcher.jar"); + // forge installer provides this out the zip (14.23.5.2851 and later), but when + // the file is removed from shared libraries, we need to add the url + library.downloads.artifact.url = Constants.FORGE_MAVEN_BASE + library.downloads.artifact.path; } // use our own mirror for Forge downloads