From ef4476a72e540e490f73f0d8cb86858ab651fdab Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sun, 23 Jun 2013 21:56:53 +0200 Subject: [PATCH] Print a warning message instead of crashing. We shouldn't prevent a plugin from adding packet listeners just because the plugin verifier failed. --- .../protocol/injector/PacketFilterManager.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java index 5666765b..b8ff35f5 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java @@ -85,6 +85,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok public static final ReportType REPORT_CANNOT_INJECT_PLAYER = new ReportType("Unable to inject player."); public static final ReportType REPORT_CANNOT_UNREGISTER_PLUGIN = new ReportType("Unable to handle disabled plugin."); + public static final ReportType REPORT_PLUGIN_VERIFIER_ERROR = new ReportType("Verifier error: %s"); /** * Sets the inject hook type. Different types allow for maximum compatibility. @@ -298,12 +299,16 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok * @param plugin - plugin to check. */ private void printPluginWarnings(Plugin plugin) { - switch (pluginVerifier.verify(plugin)) { - case NO_DEPEND: - reporter.reportWarning(this, Report.newBuilder(REPORT_PLUGIN_DEPEND_MISSING).messageParam(plugin.getName())); - case VALID: - // Do nothing - break; + try { + switch (pluginVerifier.verify(plugin)) { + case NO_DEPEND: + reporter.reportWarning(this, Report.newBuilder(REPORT_PLUGIN_DEPEND_MISSING).messageParam(plugin.getName())); + case VALID: + // Do nothing + break; + } + } catch (IllegalStateException e) { + reporter.reportWarning(this, Report.newBuilder(REPORT_PLUGIN_VERIFIER_ERROR).messageParam(e.getMessage())); } }