Added debug mode change event.

This commit is contained in:
Jeremy Wood 2019-07-30 23:03:51 -04:00
parent da6bd20b42
commit 38d5917915
3 changed files with 53 additions and 1 deletions

View File

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

View File

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

View File

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