Trying something else on NMSReflect init

This commit is contained in:
Marc Baloup 2022-06-23 19:04:31 +02:00
parent 81faece959
commit e3ba15e027
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893
2 changed files with 10 additions and 3 deletions

View File

@ -41,9 +41,15 @@ public class NMSReflect {
private static Boolean IS_SERVER_OBFUSCATED; private static Boolean IS_SERVER_OBFUSCATED;
private static boolean isInit = false;
static { static void init() {
synchronized (NMSReflect.class) {
if (isInit)
return;
isInit = true;
}
try { try {
ReflectClass<?> obfHelperClass; ReflectClass<?> obfHelperClass;
@ -90,8 +96,6 @@ public class NMSReflect {
} }
if (IS_SERVER_OBFUSCATED == null) { if (IS_SERVER_OBFUSCATED == null) {
CLASSES_BY_MOJ.clear();
CLASSES_BY_OBF.clear();
throw new IllegalStateException("Unable to determine if this server is obfuscated or not", exIfUnableToDetermine); throw new IllegalStateException("Unable to determine if this server is obfuscated or not", exIfUnableToDetermine);
} }
@ -113,6 +117,8 @@ public class NMSReflect {
throw exIfUnableToGetInstanceClass; throw exIfUnableToGetInstanceClass;
} catch (Throwable t) { } catch (Throwable t) {
Log.severe("[NMSReflect] The plugin will not be able to access NMS stuff because the obfuscation mapping couldn't be loaded.", t); Log.severe("[NMSReflect] The plugin will not be able to access NMS stuff because the obfuscation mapping couldn't be loaded.", t);
CLASSES_BY_MOJ.clear();
CLASSES_BY_OBF.clear();
} }
} }

View File

@ -471,6 +471,7 @@ public class ReflectRegistry {
*/ */
public static void init() { public static void init() {
NMSReflect.init();
initRecursively(ReflectRegistry.class); initRecursively(ReflectRegistry.class);
} }