Archiviert
13
0

Add some debug info for #202

Also /really/ make sure it's only called once
Dieser Commit ist enthalten in:
Dan Mulloy 2016-05-18 20:47:08 -04:00
Ursprung 411b7a2446
Commit c1ae6f14fc
3 geänderte Dateien mit 441 neuen und 429 gelöschten Zeilen

Datei anzeigen

@ -32,6 +32,10 @@ public class ProtocolLogger {
ProtocolLogger.logger = plugin.getLogger(); ProtocolLogger.logger = plugin.getLogger();
} }
private static boolean isDebugEnabled() {
return ProtocolLibrary.getConfig().isDebug();
}
/** /**
* Logs a message to console with a given level. * Logs a message to console with a given level.
* @param level Logging level * @param level Logging level
@ -60,4 +64,10 @@ public class ProtocolLogger {
public static void log(Level level, String message, Throwable ex) { public static void log(Level level, String message, Throwable ex) {
logger.log(level, message, ex); logger.log(level, message, ex);
} }
public static void debug(String message, Object... args) {
if (isDebugEnabled()) {
log("[Debug] " + message, args);
}
}
} }

Datei anzeigen

@ -20,6 +20,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLogger;
import com.comphenix.protocol.PacketType.Protocol; import com.comphenix.protocol.PacketType.Protocol;
import com.comphenix.protocol.PacketType.Sender; import com.comphenix.protocol.PacketType.Sender;
import com.comphenix.protocol.injector.netty.ProtocolRegistry; import com.comphenix.protocol.injector.netty.ProtocolRegistry;
@ -39,6 +40,8 @@ public class NettyProtocolRegistry extends ProtocolRegistry {
@Override @Override
protected synchronized void initialize() { protected synchronized void initialize() {
ProtocolLogger.debug("NettyProtocolRegistry#initialize()"); // Debug for issue #202
Object[] protocols = enumProtocol.getEnumConstants(); Object[] protocols = enumProtocol.getEnumConstants();
// ID to Packet class maps // ID to Packet class maps

Datei anzeigen

@ -55,17 +55,16 @@ public class PacketRegistry {
private static boolean INITIALIZED; private static boolean INITIALIZED;
/** /**
* Initialize the packet registry. * Initializes the packet registry.
*/ */
private static void initialize() { private static void initialize() {
if (INITIALIZED) { if (INITIALIZED) {
// Make sure they were initialized if (NETTY == null) {
if (NETTY == null) throw new IllegalStateException("Failed to initialize packet registry.");
throw new IllegalStateException("No initialized registry."); }
return;
} }
// Check for netty INITIALIZED = true;
NETTY = new NettyProtocolRegistry(); NETTY = new NettyProtocolRegistry();
} }