24
24
import com .falsepattern .lib .dependencies .DependencyLoader ;
25
25
import com .falsepattern .lib .dependencies .Library ;
26
26
import com .falsepattern .lib .dependencies .SemanticVersion ;
27
+ import com .falsepattern .lib .internal .Tags ;
27
28
import com .falsepattern .lib .internal .asm .CoreLoadingPlugin ;
28
29
import com .falsepattern .lib .mapping .storage .Lookup ;
29
30
import com .falsepattern .lib .mapping .types .MappingType ;
@@ -49,13 +50,15 @@ public class MappingManager {
49
50
private static final Lookup <UniversalClass > regularLookup = new Lookup <>();
50
51
private static final Map <String , String > stringPool = new HashMap <>();
51
52
private static boolean initialized = false ;
52
-
53
+ private static final Object MUTEX = new Object ();
53
54
@ SneakyThrows
54
- private static synchronized void initialize () {
55
- if (initialized ) {
56
- return ;
55
+ public static void initialize () {
56
+ synchronized (MUTEX ) {
57
+ if (initialized ) {
58
+ return ;
59
+ }
60
+ initialized = true ;
57
61
}
58
- initialized = true ;
59
62
DependencyLoader .addMavenRepo ("https://repo1.maven.org/maven2/" );
60
63
DependencyLoader .loadLibraries (Library .builder ()
61
64
.groupId ("org.tukaani" )
@@ -70,6 +73,7 @@ private static synchronized void initialize() {
70
73
.minorVersion (9 )
71
74
.patchVersion (-1 )
72
75
.build ())
76
+ .loadingModId (Tags .MODID )
73
77
.build ());
74
78
val input = new DataInputStream (new LZMA2Options (6 ).getInputStream (
75
79
ResourceUtil .getResourceFromJar ("/mappings.lzma2" , CoreLoadingPlugin .class )));
@@ -128,6 +132,7 @@ public static UniversalClass classForName(NameType nameType, MappingType mapping
128
132
129
133
@ StableAPI .Expose
130
134
public static boolean containsClass (NameType nameType , MappingType mappingType , String className ) {
135
+ initialize ();
131
136
switch (nameType ) {
132
137
case Internal :
133
138
return internalLookup .containsKey (mappingType , className );
@@ -141,6 +146,7 @@ public static boolean containsClass(NameType nameType, MappingType mappingType,
141
146
@ StableAPI .Expose
142
147
public static UniversalField getField (FieldInsnNode instruction )
143
148
throws ClassNotFoundException , NoSuchFieldException {
149
+ initialize ();
144
150
if (!CoreLoadingPlugin .isObfuscated ()) {
145
151
try {
146
152
return classForName (NameType .Internal , MappingType .MCP , instruction .owner ).getField (MappingType .MCP ,
@@ -168,6 +174,7 @@ public static UniversalField getField(FieldInsnNode instruction)
168
174
@ StableAPI .Expose
169
175
public static UniversalMethod getMethod (MethodInsnNode instruction )
170
176
throws ClassNotFoundException , NoSuchMethodException {
177
+ initialize ();
171
178
if (!CoreLoadingPlugin .isObfuscated ()) {
172
179
try {
173
180
return classForName (NameType .Internal , MappingType .MCP , instruction .owner ).getMethod (MappingType .MCP ,
0 commit comments