1
1
package com .falsepattern .lib ;
2
2
3
3
import com .falsepattern .lib .api .Version ;
4
- import com .google .common .eventbus .EventBus ;
5
- import com .google .common .eventbus .Subscribe ;
6
4
import cpw .mods .fml .common .DummyModContainer ;
7
- import cpw .mods .fml .common .FMLCommonHandler ;
8
- import cpw .mods .fml .common .LoadController ;
9
5
import cpw .mods .fml .common .ModMetadata ;
10
- import cpw .mods .fml .common .event .FMLPreInitializationEvent ;
11
6
import lombok .NonNull ;
12
7
import lombok .val ;
13
8
import lombok .var ;
18
13
import scala .actors .threadpool .Arrays ;
19
14
20
15
import javax .net .ssl .HttpsURLConnection ;
21
- import javax .swing .*;
22
16
import java .io .*;
23
17
import java .net .URL ;
24
18
import java .util .*;
25
19
26
20
27
- @ SuppressWarnings ("UnstableApiUsage" )
28
21
public class FalsePatternLib extends DummyModContainer {
29
22
public static Logger libLog = LogManager .getLogger (ModInfo .MODNAME );
30
23
public static final boolean developerEnvironment = (boolean ) Launch .blackboard .get ("fml.deobfuscatedEnvironment" );
@@ -33,12 +26,9 @@ public class FalsePatternLib extends DummyModContainer {
33
26
private static final Map <String , String > loadedLibraryMods = new HashMap <>();
34
27
private static final Set <String > mavenRepositories = new HashSet <>();
35
28
36
- private static boolean modWasDownloaded = false ;
37
-
38
29
@ SuppressWarnings ("unchecked" )
39
30
public FalsePatternLib () {
40
31
super (new ModMetadata ());
41
- libLog .info ("FalsePatternLib has been awakened!" );
42
32
libLog .info ("All your libraries are belong to us!" );
43
33
val meta = getMetadata ();
44
34
meta .modId = ModInfo .MODID ;
@@ -51,29 +41,12 @@ public FalsePatternLib() {
51
41
meta .useDependencyInformation = true ;
52
42
}
53
43
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
-
71
44
public static void addMavenRepo (String url ) {
72
45
mavenRepositories .add (url );
73
46
}
74
47
75
48
@ 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 ) {
77
50
libLog .info ("Adding library {}:{}:{}, requested by mod {}" , groupId , artifactId , preferredVersion , loadingModId );
78
51
var artifact = groupId + ":" + artifactId ;
79
52
if (loadedLibraries .containsKey (artifact )) {
@@ -105,22 +78,15 @@ public static void loadLibrary(String loadingModId, String groupId, String artif
105
78
}
106
79
val modsDir = new File (CoreLoadingPlugin .mcDir , "mods" );
107
80
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 ();
118
85
}
86
+ val file = new File (libDir , jarName );
119
87
if (file .exists ()) {
120
88
try {
121
- if (!isMod ) {
122
- addToClasspath (file );
123
- }
89
+ addToClasspath (file );
124
90
loadedLibraries .put (artifact , preferredVersion );
125
91
libLog .info ("Library {}:{}:{} successfully loaded from disk!" , groupId , artifactId , preferredVersion );
126
92
return ;
@@ -148,13 +114,6 @@ public static void loadLibrary(String loadingModId, String groupId, String artif
148
114
libLog .info ("Downloaded {}:{}:{}" , groupId , artifactId , preferredVersion );
149
115
loadedLibraries .put (artifact , preferredVersion );
150
116
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
- }
158
117
addToClasspath (file );
159
118
return ;
160
119
} catch (IOException ignored ) {}
@@ -176,7 +135,6 @@ private static void addToClasspath(File file) {
176
135
177
136
private static void download (InputStream is , File target ) throws IOException {
178
137
if (target .exists ()) return ;
179
- val name = target .getName ();
180
138
181
139
var bytesRead = 0 ;
182
140
0 commit comments