Skip to content

Commit e5bc602

Browse files
committed
Fix a few issues with the registry
1 parent a9aa406 commit e5bc602

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

modules/API/src/main/java/com/comphenix/protocol/ProtocolLogger.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ protected static void init(Plugin plugin) {
3333
}
3434

3535
private static boolean isDebugEnabled() {
36-
return ProtocolLibrary.getConfig().isDebug();
36+
try {
37+
return ProtocolLibrary.getConfig().isDebug();
38+
} catch (Throwable ex) {
39+
return true; // For testing
40+
}
3741
}
3842

3943
/**
@@ -67,7 +71,11 @@ public static void log(Level level, String message, Throwable ex) {
6771

6872
public static void debug(String message, Object... args) {
6973
if (isDebugEnabled()) {
70-
log("[Debug] " + message, args);
74+
if (logger != null) {
75+
log("[Debug] " + message, args);
76+
} else {
77+
System.out.println("[Debug] " + MessageFormat.format(message, args));
78+
}
7179
}
7280
}
7381
}

modules/API/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ public class PacketRegistry {
4343
public static final ReportType REPORT_INSUFFICIENT_SERVER_PACKETS = new ReportType("Too few server packets detected: %s");
4444
public static final ReportType REPORT_INSUFFICIENT_CLIENT_PACKETS = new ReportType("Too few client packets detected: %s");
4545

46-
// Two different packet registry
46+
// The Netty packet registry
4747
private static volatile ProtocolRegistry NETTY;
4848

4949
// Cached for Netty
5050
private static volatile Set<Integer> LEGACY_SERVER_PACKETS;
5151
private static volatile Set<Integer> LEGACY_CLIENT_PACKETS;
5252
private static volatile Map<Integer, Class> LEGACY_PREVIOUS_PACKETS;
53-
54-
// Whether or not the registry has
55-
private static boolean INITIALIZED;
53+
54+
// Whether or not the registry has been initialized
55+
private static volatile boolean INITIALIZED = false;
5656

5757
/**
5858
* Initializes the packet registry.
@@ -65,8 +65,8 @@ private static void initialize() {
6565
return;
6666
}
6767

68-
INITIALIZED = true;
6968
NETTY = new NettyProtocolRegistry();
69+
INITIALIZED = true;
7070
}
7171

7272
/**

0 commit comments

Comments
 (0)