Problem finally solved. Adjusting log messages + removing invalid and unused ReflectRegistry data

This commit is contained in:
Marc Baloup 2022-06-24 01:24:30 +02:00
parent 90ce5be020
commit 84cb9726a5
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893
2 changed files with 5 additions and 14 deletions

View File

@ -110,15 +110,13 @@ public class NMSReflect {
try { try {
clazz.cacheReflectClass(); clazz.cacheReflectClass();
} catch (Throwable e) { } catch (Throwable e) {
if (missingRuntimeClasses == 0) { // first
Log.severe("[NMSReflect] Error while loading runtime classes referenced by the obfuscation mapping.");
}
missingRuntimeClasses++; missingRuntimeClasses++;
if (e instanceof ClassNotFoundException cnfe) { if (e instanceof ClassNotFoundException cnfe) {
Log.severe("[NMSReflect] Missing runtime class " + cnfe.getMessage() + (IS_SERVER_OBFUSCATED ? (" (moj class: " + clazz.mojName + ")") : "")); Log.warning("[NMSReflect] Missing runtime class " + cnfe.getMessage() + (IS_SERVER_OBFUSCATED ? (" (moj class: " + clazz.mojName + ")") : ""));
} }
else { else {
Log.severe("[NMSReflect] Unable to load runtime class " + (IS_SERVER_OBFUSCATED ? (clazz.obfName + " (moj class: " + clazz.mojName + ")") : clazz.mojName), e); Log.warning("[NMSReflect] Unable to load runtime class " + (IS_SERVER_OBFUSCATED ? (clazz.obfName + " (moj class: " + clazz.mojName + ")") : clazz.mojName));
Log.warning(e); // throwable on separate log message due to sometimes the message not showing at all because of this exception
} }
CLASSES_BY_OBF.remove(clazz.obfName); CLASSES_BY_OBF.remove(clazz.obfName);
CLASSES_BY_MOJ.remove(clazz.mojName); CLASSES_BY_MOJ.remove(clazz.mojName);
@ -126,15 +124,13 @@ public class NMSReflect {
} }
if (missingRuntimeClasses > 0) { if (missingRuntimeClasses > 0) {
Log.severe("[NMSReflect] " + missingRuntimeClasses + " class have been removed from the mapping data due to errors."); Log.warning("[NMSReflect] " + missingRuntimeClasses + " class have been removed from the mapping data due to the previously stated errors.");
} }
} catch (Throwable t) { } catch (Throwable t) {
CLASSES_BY_OBF.clear(); CLASSES_BY_OBF.clear();
CLASSES_BY_MOJ.clear(); CLASSES_BY_MOJ.clear();
Log.severe("[NMSReflect] The plugin will have limited access to NMS stuff due to an error while loading the obfuscation mapping."); Log.severe("[NMSReflect] The plugin will not have access to NMS stuff due to an error while loading the obfuscation mapping.", t);
Log.severe(t.toString());
t.printStackTrace();
} }
Log.info("[NMSReflect] Obfuscation mapping loaded for " + CLASSES_BY_OBF.size() + " classes."); Log.info("[NMSReflect] Obfuscation mapping loaded for " + CLASSES_BY_OBF.size() + " classes.");
} }

View File

@ -109,11 +109,6 @@ public class ReflectRegistry {
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor()); public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor());
} }
public static final class BlockStateArgument {
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.blocks.BlockStateArgument"));
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor());
}
public static final class Vec3Argument { public static final class Vec3Argument {
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Vec3Argument")); public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Vec3Argument"));
public static final ReflectMethod<?> vec3 = wrapEx(() -> MAPPING.mojMethod("vec3", boolean.class)); public static final ReflectMethod<?> vec3 = wrapEx(() -> MAPPING.mojMethod("vec3", boolean.class));