From e5bc602af3eea98b8672b1e8778fd64f6d065ec2 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Wed, 18 May 2016 21:03:14 -0400 Subject: [PATCH] Fix a few issues with the registry --- .../java/com/comphenix/protocol/ProtocolLogger.java | 12 ++++++++++-- .../protocol/injector/packet/PacketRegistry.java | 10 +++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/modules/API/src/main/java/com/comphenix/protocol/ProtocolLogger.java b/modules/API/src/main/java/com/comphenix/protocol/ProtocolLogger.java index bb2a09d1..032e0d65 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/ProtocolLogger.java +++ b/modules/API/src/main/java/com/comphenix/protocol/ProtocolLogger.java @@ -33,7 +33,11 @@ public class ProtocolLogger { } private static boolean isDebugEnabled() { - return ProtocolLibrary.getConfig().isDebug(); + try { + return ProtocolLibrary.getConfig().isDebug(); + } catch (Throwable ex) { + return true; // For testing + } } /** @@ -67,7 +71,11 @@ public class ProtocolLogger { public static void debug(String message, Object... args) { if (isDebugEnabled()) { - log("[Debug] " + message, args); + if (logger != null) { + log("[Debug] " + message, args); + } else { + System.out.println("[Debug] " + MessageFormat.format(message, args)); + } } } } \ No newline at end of file diff --git a/modules/API/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java b/modules/API/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java index ed5d7a61..333a1320 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java +++ b/modules/API/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java @@ -43,16 +43,16 @@ public class PacketRegistry { public static final ReportType REPORT_INSUFFICIENT_SERVER_PACKETS = new ReportType("Too few server packets detected: %s"); public static final ReportType REPORT_INSUFFICIENT_CLIENT_PACKETS = new ReportType("Too few client packets detected: %s"); - // Two different packet registry + // The Netty packet registry private static volatile ProtocolRegistry NETTY; // Cached for Netty private static volatile Set LEGACY_SERVER_PACKETS; private static volatile Set LEGACY_CLIENT_PACKETS; private static volatile Map LEGACY_PREVIOUS_PACKETS; - - // Whether or not the registry has - private static boolean INITIALIZED; + + // Whether or not the registry has been initialized + private static volatile boolean INITIALIZED = false; /** * Initializes the packet registry. @@ -65,8 +65,8 @@ public class PacketRegistry { return; } - INITIALIZED = true; NETTY = new NettyProtocolRegistry(); + INITIALIZED = true; } /**