From 3b142db569539e06acd0afe848c2f802fb213a15 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Wed, 19 Dec 2012 23:10:50 +0100 Subject: [PATCH] Don't ignore critical exceptions - print them. --- .../java/com/comphenix/protocol/ProtocolLibrary.java | 11 ++++++++++- .../comphenix/protocol/injector/BukkitUnwrapper.java | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index 2f5b4774..3cf0e1ab 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -65,7 +65,7 @@ public class ProtocolLibrary extends JavaPlugin { private static PacketFilterManager protocolManager; // Error reporter - private ErrorReporter reporter; + private static ErrorReporter reporter; // Metrics and statistisc private Statistics statistisc; @@ -353,6 +353,7 @@ public class ProtocolLibrary extends JavaPlugin { protocolManager.close(); protocolManager = null; statistisc = null; + reporter = null; // Leaky ClassLoader begone! CleanupStaticMembers cleanup = new CleanupStaticMembers(getClassLoader(), reporter); @@ -373,6 +374,14 @@ public class ProtocolLibrary extends JavaPlugin { return log; } + /** + * Retrieve the current error reporter. + * @return Current error reporter. + */ + public static ErrorReporter getErrorReporter() { + return reporter; + } + /** * Retrieves the packet protocol manager. * @return Packet protocol manager, or NULL if it has been disabled. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java index 147e2087..40420214 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.injector.PacketConstructor.Unwrapper; import com.comphenix.protocol.reflect.instances.DefaultInstances; @@ -107,8 +108,10 @@ public class BukkitUnwrapper implements Unwrapper { return find; } catch (SecurityException e) { + ProtocolLibrary.getErrorReporter().reportDetailed(this, "Security limitation.", e, type); return null; } catch (NoSuchMethodException e) { + ProtocolLibrary.getErrorReporter().reportDetailed(this, "Cannot unwrap object.", e, type); return null; } }