From 766bb43a5fdd34ffda547c3eb57865b582067ec3 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Fri, 24 Jun 2022 00:14:53 +0200 Subject: [PATCH] Adding more logging in NMSReflect --- .../lib/paper/reflect/NMSReflect.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java b/Paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java index 6ed8681..63ad719 100644 --- a/Paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java +++ b/Paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java @@ -81,13 +81,11 @@ public class NMSReflect { try { Class.forName(clazz.obfName); IS_SERVER_OBFUSCATED = true; - Log.info("[NMSReflect] NMS classes are obfuscated."); break; } catch (ClassNotFoundException e) { try { Class.forName(clazz.mojName); IS_SERVER_OBFUSCATED = false; - Log.info("[NMSReflect] NMS classes are using mojang mapping."); break; } catch (ClassNotFoundException ee) { ee.addSuppressed(e); @@ -100,27 +98,31 @@ public class NMSReflect { if (IS_SERVER_OBFUSCATED == null) { throw new IllegalStateException("Unable to determine if this server is obfuscated or not", exIfUnableToDetermine); } + if (IS_SERVER_OBFUSCATED) { + Log.info("[NMSReflect] NMS runtime classes are obfuscated."); + } + else { + Log.info("[NMSReflect] NMS runtime classes are mojang mapped."); + } - - ClassNotFoundException exIfUnableToGetInstanceClass = null; + boolean missingRuntimeClasses = false; for (ClassMapping clazz : mappings) { try { clazz.cacheReflectClass(); } catch (ClassNotFoundException e) { - if (exIfUnableToGetInstanceClass == null) - exIfUnableToGetInstanceClass = e; - else { - exIfUnableToGetInstanceClass.addSuppressed(e); - } + missingRuntimeClasses = true; + Log.severe("[NMSReflect] Missing runtime class " + e.getMessage() + (IS_SERVER_OBFUSCATED ? (" (moj class: " + clazz.mojName + ")") : "")); } } - if (exIfUnableToGetInstanceClass != null) - throw exIfUnableToGetInstanceClass; + if (missingRuntimeClasses) + throw new ClassNotFoundException("Unable to find all the following runtime classes referenced by the obfuscation mapping. They are removed from the mapping data."); Log.info("[NMSReflect] Obfuscation mapping loaded for " + mappings.size() + " classes."); } 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 hava limited access to access NMS stuff due to an error while loading the obfuscation mapping."); + Log.severe(t.toString()); + Log.severe(t); CLASSES_BY_MOJ.clear(); CLASSES_BY_OBF.clear(); }