From 6774479a0338c57de0ba88fe0e054085c92b45d0 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Fri, 26 Jan 2024 20:54:00 +0800 Subject: [PATCH] Update download mirrors (#1200) --- .../arclight/forgeinstaller/ForgeInstaller.java | 4 +++- .../arclight/forgeinstaller/MavenDownloader.java | 12 +++++------- .../io/izzel/arclight/forgeinstaller/Mirrors.java | 8 +++++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java index 5ea43b8a8..45b56f3dd 100644 --- a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java +++ b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java @@ -92,7 +92,9 @@ public static Map.Entry> applicationInstall() throws Throwa builder.command(file.getCanonicalPath(), "-Djava.net.useSystemProxies=true", "-jar", futures[0].join().toString(), "--installServer", ".", "--debug"); builder.inheritIO(); Process process = builder.start(); - process.waitFor(); + if (process.waitFor() > 0) { + throw new Exception("Forge installation failed"); + } } catch (IOException e) { try (URLClassLoader loader = new URLClassLoader( new URL[]{new File(String.format("forge-%s-%s-installer.jar", installInfo.installer.minecraft, installInfo.installer.forge)).toURI().toURL()}, diff --git a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/MavenDownloader.java b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/MavenDownloader.java index 9a77540d2..9d1f87312 100644 --- a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/MavenDownloader.java +++ b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/MavenDownloader.java @@ -5,15 +5,10 @@ import java.util.LinkedList; import java.util.List; import java.util.StringJoiner; -import java.util.function.Function; import java.util.function.Supplier; public class MavenDownloader implements Supplier { - private static final Function FORGE_TO_BMCLAPI = - s -> s.replace("https://files.minecraftforge.net/maven/", "https://download.mcbbs.net/maven/") - .replace("https://maven.minecraftforge.net/", "https://download.mcbbs.net/maven/"); - private final LinkedList urls; private final String coord; private final String target; @@ -33,8 +28,11 @@ public MavenDownloader(String[] repos, String coord, String target, String hash) public MavenDownloader(String[] repos, String coord, String target, String hash, String sourceUrl) { this(repos, coord, target, hash); if (sourceUrl != null && !this.urls.contains(sourceUrl)) { - this.urls.addFirst(sourceUrl); - this.urls.addFirst(FORGE_TO_BMCLAPI.apply(sourceUrl)); + if (Mirrors.isMirrorUrl(sourceUrl)) { + this.urls.addFirst(sourceUrl); + } else { + this.urls.addLast(sourceUrl); + } } } diff --git a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/Mirrors.java b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/Mirrors.java index a0fee64c5..d33198828 100644 --- a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/Mirrors.java +++ b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/Mirrors.java @@ -9,13 +9,11 @@ public class Mirrors { private static final String[] MAVEN_REPO = { "https://arclight.hypertention.cn/", - "https://download.mcbbs.net/maven/", "https://repo.spongepowered.org/maven/" }; private static final String[] MOJANG_MIRROR = { - "https://download.mcbbs.net", - "https://bmclapi2.bangbang93.com", + "https://mojmirror.hypertention.cn", "https://piston-meta.mojang.com" }; @@ -39,4 +37,8 @@ public static String mapMojangMirror(String url, String mirror) { .replace("https://piston-meta.mojang.com", mirror) .replace("https://piston-data.mojang.com", mirror); } + + public static boolean isMirrorUrl(String url) { + return url.startsWith(MOJANG_MIRROR[0]); + } }