From e45ac45ac6ae080771ae73e2834cb2eddcc52c5d Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 23 Jun 2022 23:54:52 +0200 Subject: [PATCH] Still trying to undestand where is the problem --- .../java/fr/pandacube/lib/core/util/ThrowableUtil.java | 8 ++++++-- .../java/fr/pandacube/lib/paper/reflect/NMSReflect.java | 4 ++++ .../fr/pandacube/lib/paper/reflect/ReflectRegistry.java | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/fr/pandacube/lib/core/util/ThrowableUtil.java b/Core/src/main/java/fr/pandacube/lib/core/util/ThrowableUtil.java index 515762e..521443f 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/util/ThrowableUtil.java +++ b/Core/src/main/java/fr/pandacube/lib/core/util/ThrowableUtil.java @@ -40,12 +40,14 @@ public class ThrowableUtil { * Wraps a {@link SupplierException} into a try catch. * @param supp the {@link SupplierException} to run and get the value from. * @return the value returned by the provided supplier. - * @throws RuntimeException if the provided {@link SupplierException} throws an exception. + * @throws RuntimeException if the provided {@link SupplierException} throws a checked exception. */ public static T wrapEx(SupplierException supp) { try { return supp.get(); } catch (Exception e) { + if (e instanceof RuntimeException re) + throw re; throw new RuntimeException(e); } } @@ -63,12 +65,14 @@ public class ThrowableUtil { /** * Wraps a {@link RunnableException} into a try catch. * @param run the {@link RunnableException} to run. - * @throws RuntimeException if the provided {@link RunnableException} throws an exception. + * @throws RuntimeException if the provided {@link RunnableException} throws a checked exception. */ public static void wrapEx(RunnableException run) { try { run.run(); } catch (Exception e) { + if (e instanceof RuntimeException re) + throw re; throw new RuntimeException(e); } } 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 4a785fa..6ed8681 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 @@ -51,6 +51,8 @@ public class NMSReflect { isInit = true; } + Log.info("[NMSReflect] Initializing NMS obfuscation mapping..."); + try { ReflectClass obfHelperClass; try { @@ -115,6 +117,8 @@ public class NMSReflect { if (exIfUnableToGetInstanceClass != null) throw exIfUnableToGetInstanceClass; + + 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); CLASSES_BY_MOJ.clear(); diff --git a/Paper/src/main/java/fr/pandacube/lib/paper/reflect/ReflectRegistry.java b/Paper/src/main/java/fr/pandacube/lib/paper/reflect/ReflectRegistry.java index 09f2634..0f70530 100644 --- a/Paper/src/main/java/fr/pandacube/lib/paper/reflect/ReflectRegistry.java +++ b/Paper/src/main/java/fr/pandacube/lib/paper/reflect/ReflectRegistry.java @@ -424,7 +424,7 @@ public class ReflectRegistry { public static final ReflectField chunks = wrapEx(() -> REFLECT.field("chunks")); public static final class Chunks { - public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.configuration.WorldConfiguration.Chunks")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.configuration.WorldConfiguration$Chunks")); public static final ReflectField autoSavePeriod = wrapEx(() -> REFLECT.field("autoSaveInterval")); } } @@ -492,6 +492,9 @@ public class ReflectRegistry { f.get(null); } } catch (Throwable t) { + if (t instanceof ExceptionInInitializerError eiie && eiie.getCause() != null) { + t = eiie.getCause(); + } Log.severe("Error while initilizing a ReflectRegistry entry at " + cl.getName(), t); } for (Class declaredClass : cl.getDeclaredClasses()) {