mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-03-12 22:59:14 +01:00
Add some debug info for #202
Also /really/ make sure it's only called once
This commit is contained in:
parent
411b7a2446
commit
c1ae6f14fc
@ -32,6 +32,10 @@ public class ProtocolLogger {
|
||||
ProtocolLogger.logger = plugin.getLogger();
|
||||
}
|
||||
|
||||
private static boolean isDebugEnabled() {
|
||||
return ProtocolLibrary.getConfig().isDebug();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message to console with a given level.
|
||||
* @param level Logging level
|
||||
@ -60,4 +64,10 @@ public class ProtocolLogger {
|
||||
public static void log(Level level, String message, Throwable ex) {
|
||||
logger.log(level, message, ex);
|
||||
}
|
||||
|
||||
public static void debug(String message, Object... args) {
|
||||
if (isDebugEnabled()) {
|
||||
log("[Debug] " + message, args);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLogger;
|
||||
import com.comphenix.protocol.PacketType.Protocol;
|
||||
import com.comphenix.protocol.PacketType.Sender;
|
||||
import com.comphenix.protocol.injector.netty.ProtocolRegistry;
|
||||
@ -39,6 +40,8 @@ public class NettyProtocolRegistry extends ProtocolRegistry {
|
||||
|
||||
@Override
|
||||
protected synchronized void initialize() {
|
||||
ProtocolLogger.debug("NettyProtocolRegistry#initialize()"); // Debug for issue #202
|
||||
|
||||
Object[] protocols = enumProtocol.getEnumConstants();
|
||||
|
||||
// ID to Packet class maps
|
||||
|
@ -55,17 +55,16 @@ public class PacketRegistry {
|
||||
private static boolean INITIALIZED;
|
||||
|
||||
/**
|
||||
* Initialize the packet registry.
|
||||
* Initializes the packet registry.
|
||||
*/
|
||||
private static void initialize() {
|
||||
if (INITIALIZED) {
|
||||
// Make sure they were initialized
|
||||
if (NETTY == null)
|
||||
throw new IllegalStateException("No initialized registry.");
|
||||
return;
|
||||
if (NETTY == null) {
|
||||
throw new IllegalStateException("Failed to initialize packet registry.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check for netty
|
||||
INITIALIZED = true;
|
||||
NETTY = new NettyProtocolRegistry();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user