Fix a few issues with the registry

This commit is contained in:
Dan Mulloy 2016-05-18 21:03:14 -04:00
parent a9aa406d29
commit e5bc602af3
2 changed files with 15 additions and 7 deletions

View File

@ -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));
}
}
}
}

View File

@ -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<Integer> LEGACY_SERVER_PACKETS;
private static volatile Set<Integer> LEGACY_CLIENT_PACKETS;
private static volatile Map<Integer, Class> 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;
}
/**