diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index a25cc27d..3b3bcd7d 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -78,6 +78,7 @@ import com.onarandombox.MultiverseCore.destination.DestinationFactory; import com.onarandombox.MultiverseCore.destination.ExactDestination; import com.onarandombox.MultiverseCore.destination.PlayerDestination; import com.onarandombox.MultiverseCore.destination.WorldDestination; +import com.onarandombox.MultiverseCore.event.MVDebugModeEvent; import com.onarandombox.MultiverseCore.event.MVVersionEvent; import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener; import com.onarandombox.MultiverseCore.listeners.MVChatListener; @@ -309,7 +310,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { // Setup & Load our Configuration files. loadConfigs(); if (this.multiverseConfig != null) { - Logging.setDebugLevel(getMVConfig().getGlobalDebug()); Logging.setShowingConfig(!getMVConfig().getSilentStart()); this.worldManager.loadDefaultWorlds(); this.worldManager.loadWorlds(true); @@ -518,6 +518,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { // Old Config Format this.migrate22Values(); this.saveMVConfigs(); + + int level = Logging.getDebugLevel(); + Logging.setDebugLevel(getMVConfig().getGlobalDebug()); + if (level != Logging.getDebugLevel()) { + getServer().getPluginManager().callEvent(new MVDebugModeEvent(level)); + } } /** diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java index 65142f81..1f295dbb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java @@ -2,7 +2,9 @@ package com.onarandombox.MultiverseCore; import com.dumptruckman.minecraft.util.*; import com.onarandombox.MultiverseCore.api.*; +import com.onarandombox.MultiverseCore.event.MVDebugModeEvent; import me.main__.util.SerializationConfig.*; +import org.bukkit.Bukkit; import java.util.*; @@ -229,6 +231,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements public void setGlobalDebug(int globalDebug) { this.globaldebug = globalDebug; Logging.setDebugLevel(globalDebug); + Bukkit.getPluginManager().callEvent(new MVDebugModeEvent(globalDebug)); } /** diff --git a/src/main/java/com/onarandombox/MultiverseCore/event/MVDebugModeEvent.java b/src/main/java/com/onarandombox/MultiverseCore/event/MVDebugModeEvent.java new file mode 100644 index 00000000..f3c3408b --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/event/MVDebugModeEvent.java @@ -0,0 +1,43 @@ +package com.onarandombox.MultiverseCore.event; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Called when Core's debug level is changed. + */ +public class MVDebugModeEvent extends Event { + + private static final HandlerList HANDLERS = new HandlerList(); + + private final int level; + + public MVDebugModeEvent(int level) { + this.level = level; + } + + /** + * {@inheritDoc} + */ + @Override + public HandlerList getHandlers() { + return HANDLERS; + } + + /** + * Gets the handler list. This is required by the event system. + * @return A list of HANDLERS. + */ + public static HandlerList getHandlerList() { + return HANDLERS; + } + + /** + * Returns the current debug level of Core. + * + * @return the current debug level of Core. + */ + public int getLevel() { + return level; + } +}