@@ -31,8 +31,10 @@ GSON_DEPENDENCY, new Dependency("com.google.guava:guava:21.0", MAVEN_CENTRAL, "c
3131 new Dependency ("org.apache.commons:commons-lang3:3.3.2" , MAVEN_CENTRAL , "org.apache.commons.lang3.tuple.Pair" ),
3232 new Dependency ("org.luaj:luaj-jse:3.0.1" , MAVEN_CENTRAL , "org.luaj.vm2.Globals" ),
3333 new Dependency ("org.spongepowered:mixin:0.8.5" , SPONGE_POWERED , "org.spongepowered.asm.mixin.Mixins" ),
34- new Dependency ("com.github.LlamaLad7.MixinExtras:mixinextras-common:0.2.0-beta.8" ,
35- JITPACK , "com.llamalad7.mixinextras.MixinExtrasBootstrap" ),
34+ new Dependency ("com.github.LlamaLad7.MixinExtras:mixinextras-common:0.2.0-beta.9" ,
35+ JITPACK , "com.llamalad7.mixinextras.MixinExtrasBootstrap" ,
36+ // Need fallback URL cause JitPack links can ded at any time
37+ "https://github.com/LlamaLad7/MixinExtras/releases/download/0.2.0-beta.9/mixinextras-common-0.2.0-beta.9.jar" ),
3638 };
3739
3840 public static final Dependency sparkDependency =
@@ -142,13 +144,27 @@ private static File loadDependencyImpl(Dependency dependency, boolean minecraft,
142144 if (!parentFile .isDirectory () && !parentFile .mkdirs ()) {
143145 throw new RuntimeException ("Cannot create dependency directory for " + dependency .name );
144146 }
147+ IOException fallBackIoe = null ;
145148 try (OutputStream os = Files .newOutputStream (file .toPath ())) {
146149 justDownloaded = true ;
147150 NetUtils .downloadTo (new URL (dependency .repository .endsWith (".jar" ) ?
148151 dependency .repository : dependency .repository + "/" + postURL ), os );
149152 } catch (IOException ioe ) {
150- if (file .exists () && !file .delete ()) file .deleteOnExit ();
151- throw new RuntimeException ("Cannot download " + dependency .name , ioe );
153+ if (dependency .fallbackUrl != null ) {
154+ fallBackIoe = ioe ;
155+ } else {
156+ if (file .exists () && !file .delete ()) file .deleteOnExit ();
157+ throw new RuntimeException ("Cannot download " + dependency .name , ioe );
158+ }
159+ }
160+ if (fallBackIoe != null ) {
161+ try (OutputStream os = Files .newOutputStream (file .toPath ())) {
162+ justDownloaded = true ;
163+ NetUtils .downloadTo (new URL (dependency .fallbackUrl ), os );
164+ } catch (IOException ioe ) {
165+ if (file .exists () && !file .delete ()) file .deleteOnExit ();
166+ throw new RuntimeException ("Cannot download " + dependency .name , fallBackIoe );
167+ }
152168 }
153169 }
154170 if (dev ) return file ; // We don't have a FoxClass loader in dev environment.
@@ -286,12 +302,17 @@ private static String resolvePostURL(String string) {
286302 }
287303
288304 public static class Dependency {
289- public final String name , repository , classCheck ;
305+ public final String name , repository , classCheck , fallbackUrl ;
290306
291307 public Dependency (String name , String repository , String classCheck ) {
308+ this (name , repository , classCheck , null );
309+ }
310+
311+ public Dependency (String name , String repository , String classCheck , String fallbackUrl ) {
292312 this .name = name ;
293313 this .repository = repository ;
294314 this .classCheck = classCheck ;
315+ this .fallbackUrl = fallbackUrl ;
295316 }
296317 }
297318}
0 commit comments