11package com .falsepattern .lib ;
22
33import com .falsepattern .lib .api .Version ;
4- import com .google .common .eventbus .EventBus ;
5- import com .google .common .eventbus .Subscribe ;
64import cpw .mods .fml .common .DummyModContainer ;
7- import cpw .mods .fml .common .FMLCommonHandler ;
8- import cpw .mods .fml .common .LoadController ;
95import cpw .mods .fml .common .ModMetadata ;
10- import cpw .mods .fml .common .event .FMLPreInitializationEvent ;
116import lombok .NonNull ;
127import lombok .val ;
138import lombok .var ;
1813import scala .actors .threadpool .Arrays ;
1914
2015import javax .net .ssl .HttpsURLConnection ;
21- import javax .swing .*;
2216import java .io .*;
2317import java .net .URL ;
2418import java .util .*;
2519
2620
27- @ SuppressWarnings ("UnstableApiUsage" )
2821public class FalsePatternLib extends DummyModContainer {
2922 public static Logger libLog = LogManager .getLogger (ModInfo .MODNAME );
3023 public static final boolean developerEnvironment = (boolean ) Launch .blackboard .get ("fml.deobfuscatedEnvironment" );
@@ -33,12 +26,9 @@ public class FalsePatternLib extends DummyModContainer {
3326 private static final Map <String , String > loadedLibraryMods = new HashMap <>();
3427 private static final Set <String > mavenRepositories = new HashSet <>();
3528
36- private static boolean modWasDownloaded = false ;
37-
3829 @ SuppressWarnings ("unchecked" )
3930 public FalsePatternLib () {
4031 super (new ModMetadata ());
41- libLog .info ("FalsePatternLib has been awakened!" );
4232 libLog .info ("All your libraries are belong to us!" );
4333 val meta = getMetadata ();
4434 meta .modId = ModInfo .MODID ;
@@ -51,29 +41,12 @@ public FalsePatternLib() {
5141 meta .useDependencyInformation = true ;
5242 }
5343
54- @ Override
55- public boolean registerBus (EventBus bus , LoadController controller ) {
56- bus .register (this );
57-
58- return true ;
59- }
60-
61- @ Subscribe
62- public void preInit (FMLPreInitializationEvent evt ) {
63- if (modWasDownloaded ) {
64- JOptionPane .showMessageDialog (null ,
65- "A mod has downloaded another mod as a dependency, and the game requires a restart so that the " +
66- "downloaded mod is initialized properly! After you close this popup, FalsePatternLib will close the game." , "Reload Required" , JOptionPane .WARNING_MESSAGE , null );
67- FMLCommonHandler .instance ().exitJava (0 , false );
68- }
69- }
70-
7144 public static void addMavenRepo (String url ) {
7245 mavenRepositories .add (url );
7346 }
7447
7548 @ SuppressWarnings ("ResultOfMethodCallIgnored" )
76- public static void loadLibrary (String loadingModId , String groupId , String artifactId , @ NonNull Version minVersion , Version maxVersion , @ NonNull Version preferredVersion , String devSuffix , boolean isMod ) {
49+ public static void loadLibrary (String loadingModId , String groupId , String artifactId , @ NonNull Version minVersion , Version maxVersion , @ NonNull Version preferredVersion , String devSuffix ) {
7750 libLog .info ("Adding library {}:{}:{}, requested by mod {}" , groupId , artifactId , preferredVersion , loadingModId );
7851 var artifact = groupId + ":" + artifactId ;
7952 if (loadedLibraries .containsKey (artifact )) {
@@ -105,22 +78,15 @@ public static void loadLibrary(String loadingModId, String groupId, String artif
10578 }
10679 val modsDir = new File (CoreLoadingPlugin .mcDir , "mods" );
10780 val mavenJarName = String .format ("%s-%s%s.jar" , artifactId , preferredVersion , (developerEnvironment && devSuffix != null ) ? ("-" + devSuffix ) : "" );
108- val jarName = String .format ("%s%s" , isMod ? "" : (groupId + "-" ), mavenJarName );
109- File file ;
110- if (isMod ) {
111- file = new File (modsDir , jarName );
112- } else {
113- val libDir = new File (modsDir , "falsepattern" );
114- if (!libDir .exists ()) {
115- libDir .mkdirs ();
116- }
117- file = new File (libDir , jarName );
81+ val jarName = groupId + "-" + mavenJarName ;
82+ val libDir = new File (modsDir , "falsepattern" );
83+ if (!libDir .exists ()) {
84+ libDir .mkdirs ();
11885 }
86+ val file = new File (libDir , jarName );
11987 if (file .exists ()) {
12088 try {
121- if (!isMod ) {
122- addToClasspath (file );
123- }
89+ addToClasspath (file );
12490 loadedLibraries .put (artifact , preferredVersion );
12591 libLog .info ("Library {}:{}:{} successfully loaded from disk!" , groupId , artifactId , preferredVersion );
12692 return ;
@@ -148,13 +114,6 @@ public static void loadLibrary(String loadingModId, String groupId, String artif
148114 libLog .info ("Downloaded {}:{}:{}" , groupId , artifactId , preferredVersion );
149115 loadedLibraries .put (artifact , preferredVersion );
150116 loadedLibraryMods .put (artifact , loadingModId );
151- if (isMod ) {
152- if (!modWasDownloaded ) {
153- modWasDownloaded = true ;
154- libLog .warn ("A Minecraft mod was downloaded as a library! This will require a game restart! The game restart will trigger on preInit!" );
155- }
156- return ;
157- }
158117 addToClasspath (file );
159118 return ;
160119 } catch (IOException ignored ) {}
@@ -176,7 +135,6 @@ private static void addToClasspath(File file) {
176135
177136 private static void download (InputStream is , File target ) throws IOException {
178137 if (target .exists ()) return ;
179- val name = target .getName ();
180138
181139 var bytesRead = 0 ;
182140
0 commit comments