Set a default debugger during the load phase to avoid null errors

This commit is contained in:
Flowsqy 2022-12-31 17:49:26 +01:00
parent c8035de739
commit ef1479dfdc

View File

@ -68,6 +68,9 @@ public class ShopChest extends JavaPlugin {
public void onLoad() {
instance = this;
// Set a default debugger
this.debugLogger = new NullDebugLogger(getLogger());
configManager = new ConfigManager(this, getDataFolder());
if (!configManager.checkDataFolder()) {
@ -159,7 +162,6 @@ public class ShopChest extends JavaPlugin {
*/
private void cancelLoading(String reason) {
final String disableMessage = "Disabling the plugin";
final DebugLogger debugLogger = this.debugLogger != null ? this.debugLogger : new NullDebugLogger(getLogger());
debugLogger.debug(reason);
debugLogger.debug(disableMessage);
debugLogger.getLogger().warning(reason);