diff --git a/modules/API/src/main/java/com/comphenix/protocol/ProtocolConfig.java b/modules/API/src/main/java/com/comphenix/protocol/ProtocolConfig.java index f0854da4..74e438d3 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/ProtocolConfig.java +++ b/modules/API/src/main/java/com/comphenix/protocol/ProtocolConfig.java @@ -157,6 +157,9 @@ public class ProtocolConfig { } if (global != null) { updater = global.getConfigurationSection(SECTION_AUTOUPDATER); + if (updater.getValues(true).isEmpty()) { + plugin.getLogger().warning("Updater section is missing, regenerate your config!"); + } } // Automatically copy defaults diff --git a/modules/API/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/modules/API/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index f19a6d1c..8ddce6a2 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/ProtocolLibrary.java +++ b/modules/API/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -71,7 +71,6 @@ public class ProtocolLibrary { ProtocolLibrary.reporter = reporter; ProtocolLibrary.executorAsync = executorAsync; ProtocolLibrary.executorSync = executorSync; - ProtocolLogger.init(plugin); initialized = true; } 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 c3f7b3f7..6b33a72e 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/ProtocolLogger.java +++ b/modules/API/src/main/java/com/comphenix/protocol/ProtocolLogger.java @@ -18,7 +18,6 @@ package com.comphenix.protocol; import java.text.MessageFormat; import java.util.logging.Level; -import java.util.logging.Logger; import org.bukkit.plugin.Plugin; @@ -26,17 +25,17 @@ import org.bukkit.plugin.Plugin; * @author dmulloy2 */ public class ProtocolLogger { - private static Logger logger; + private static Plugin plugin; protected static void init(Plugin plugin) { - ProtocolLogger.logger = plugin.getLogger(); + ProtocolLogger.plugin = plugin; } private static boolean isDebugEnabled() { try { - return ProtocolLibrary.getConfig().isDebug(); - } catch (Throwable ex) { - return true; // For testing + return plugin.getConfig().getBoolean("global.debug", false); + } catch (Throwable ex) { // Maybe we're testing or something + return false; } } @@ -47,7 +46,7 @@ public class ProtocolLogger { * @param args Arguments to format in */ public static void log(Level level, String message, Object... args) { - logger.log(level, MessageFormat.format(message, args)); + plugin.getLogger().log(level, MessageFormat.format(message, args)); } /** @@ -66,16 +65,12 @@ public class ProtocolLogger { * @param ex Exception to log */ public static void log(Level level, String message, Throwable ex) { - logger.log(level, message, ex); + plugin.getLogger().log(level, message, ex); } public static void debug(String message, Object... args) { if (isDebugEnabled()) { - if (logger != null) { - log("[Debug] " + message, args); - } else { - System.out.println("[Debug] " + MessageFormat.format(message, args)); - } + log("[Debug] " + message, args); } } } diff --git a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java index 7eaa1594..3264cc10 100644 --- a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java +++ b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java @@ -148,8 +148,10 @@ public class ProtocolLib extends JavaPlugin { @Override public void onLoad() { - // Load configuration + // Logging logger = getLoggerSafely(); + ProtocolLogger.init(this); + Application.registerPrimaryThread(); // Initialize enhancer factory