Added ability to set debug level to -1 to disable common startup messages.

This commit is contained in:
Jeremy Wood 2012-10-25 10:43:57 -04:00
parent b1fa677330
commit af3b3d0fab

View File

@ -23,7 +23,7 @@ public class DebugCommand extends MultiverseCommand {
public DebugCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Turn Debug on/off?");
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off]");
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off|-1]");
this.setArgRange(0, 1);
this.addKey("mv debug");
this.addKey("mv d");
@ -40,13 +40,13 @@ public class DebugCommand extends MultiverseCommand {
} else {
try {
int debugLevel = Integer.parseInt(args.get(0));
if (debugLevel > 3 || debugLevel < 0) {
if (debugLevel > 3 || debugLevel < -1) {
throw new NumberFormatException();
}
plugin.getMVConfig().setGlobalDebug(debugLevel);
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
+ " setting debug level. Please use a number 0-3 or -1 " + ChatColor.AQUA + "(3 being many many messages! -1 disables common messages!)");
}
}
plugin.saveMVConfigs();
@ -55,11 +55,14 @@ public class DebugCommand extends MultiverseCommand {
}
private void displayDebugMode(CommandSender sender) {
if (plugin.getMVConfig().getGlobalDebug() == 0) {
final int debugLevel = plugin.getMVConfig().getGlobalDebug();
if (debugLevel == 0) {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
} else {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + plugin.getMVConfig().getGlobalDebug());
} else if (debugLevel > 0) {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
} else {
sender.sendMessage("Multiverse Debug mode is" + ChatColor.GRAY + " disabling common startup messages!");
}
}
}