Add command to enable/disable debug mode without restarting the server.

This commit is contained in:
Thijs Alders committed 2021-02-05 18:30:54 +01:00
1 parent 03d7adde87
commit e22dd9fe31
3 files changed
+61 -3

No files matched your search

@@ -44,6 +44,35 @@ public class CraftingStoreCommand implements CommandExecutor {
});
return true;
}
if (args.length == 1 || args.length == 2 && args[0].equalsIgnoreCase("debug")) {
boolean isDebugging = this.instance.getCraftingStore().getLogger().isDebugging();
if (args.length == 1) {
sender.sendMessage(String.format(
"%sDebug mode is currently %s.",
this.instance.getPrefix(),
isDebugging ? "enabled" : "disabled"
));
return true;
}
String debugValue = args[1].toLowerCase();
if (debugValue.equalsIgnoreCase("true")) {
isDebugging = true;
} else if (debugValue.equalsIgnoreCase("false")) {
isDebugging = false;
} else {
sender.sendMessage(instance.getPrefix() + "Unknown debug value.");
return true;
}
this.instance.getCraftingStore().getLogger().setDebugging(isDebugging);
instance.getConfig().set("debug", isDebugging);
instance.getConfigWrapper().saveConfig();
sender.sendMessage(String.format(
"%sDebug mode has been %s.",
this.instance.getPrefix(),
isDebugging ? "enabled" : "disabled"
));
return true;
}
sender.sendMessage(ChatColor.GRAY + "" +ChatColor.STRIKETHROUGH + "-----------------------");
sender.sendMessage(ChatColor.DARK_GRAY + ">" + ChatColor.GRAY + " /" + label + " reload" + ChatColor.DARK_GRAY + " -> " + ChatColor.GRAY + "Reload the config.");
@@ -44,10 +44,39 @@ public class CraftingStoreCommand extends Command {
});
return;
}
if (args.length == 1 || args.length == 2 && args[0].equalsIgnoreCase("debug")) {
boolean isDebugging = this.instance.getCraftingStore().getLogger().isDebugging();
if (args.length == 1) {
sender.sendMessage(new TextComponent(String.format(
"%sDebug mode is currently %s.",
this.instance.getPrefix(),
isDebugging ? "enabled" : "disabled"
)));
return;
}
String debugValue = args[1].toLowerCase();
if (debugValue.equalsIgnoreCase("true")) {
isDebugging = true;
} else if (debugValue.equalsIgnoreCase("false")) {
isDebugging = false;
} else {
sender.sendMessage(new TextComponent(instance.getPrefix() + "Unknown debug value."));
return;
}
this.instance.getCraftingStore().getLogger().setDebugging(isDebugging);
instance.getConfig().set("debug", isDebugging);
instance.getConfigWrapper().saveConfig();
sender.sendMessage(new TextComponent(String.format(
"%sDebug mode has been %s.",
this.instance.getPrefix(),
isDebugging ? "enabled" : "disabled"
)));
return;
}
sender.sendMessage(new TextComponent(ChatColor.GRAY + "" +ChatColor.STRIKETHROUGH + "-----------------------"));
sender.sendMessage(new TextComponent(ChatColor.GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------------"));
sender.sendMessage(new TextComponent(ChatColor.DARK_GRAY + ">" + ChatColor.GRAY + " /csb reload" + ChatColor.DARK_GRAY + " -> " + ChatColor.GRAY + "Reload the config."));
sender.sendMessage(new TextComponent(ChatColor.DARK_GRAY + ">" + ChatColor.GRAY + " /csb key <your key>" + ChatColor.DARK_GRAY + " -> " + ChatColor.GRAY + "Update the key."));
sender.sendMessage(new TextComponent(ChatColor.GRAY + "" +ChatColor.STRIKETHROUGH + "-----------------------"));
sender.sendMessage(new TextComponent(ChatColor.GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------------"));
}
}
+1 -1
View File
@@ -11,7 +11,7 @@
<properties>
<revision>${craftingstore-version}-RELEASE</revision>
<craftingstore-version>2.6.2</craftingstore-version>
<craftingstore-version>2.6.3</craftingstore-version>
</properties>
<build>