diff --git a/src/main/java/com/graywolf336/jail/JailMain.java b/src/main/java/com/graywolf336/jail/JailMain.java index 287661f..ab2da76 100644 --- a/src/main/java/com/graywolf336/jail/JailMain.java +++ b/src/main/java/com/graywolf336/jail/JailMain.java @@ -233,8 +233,14 @@ public class JailMain extends JavaPlugin { } /** Sets whether the plugin is in debugging or not. */ - public void setDebugging(boolean debug) { + public boolean setDebugging(boolean debug) { this.debug = debug; + + //Save whether we are debugging when we disable the plugin + getConfig().set(Settings.DEBUG.getPath(), this.debug); + saveConfig(); + + return this.debug; } /** Returns if the plugin is in debug state or not. */ diff --git a/src/main/java/com/graywolf336/jail/command/CommandHandler.java b/src/main/java/com/graywolf336/jail/command/CommandHandler.java index 190a499..1d654fd 100644 --- a/src/main/java/com/graywolf336/jail/command/CommandHandler.java +++ b/src/main/java/com/graywolf336/jail/command/CommandHandler.java @@ -11,6 +11,7 @@ import org.bukkit.entity.Player; import com.graywolf336.jail.JailMain; import com.graywolf336.jail.JailManager; import com.graywolf336.jail.command.commands.HandCuffCommand; +import com.graywolf336.jail.command.commands.ToggleJailDebugCommand; import com.graywolf336.jail.command.commands.UnHandCuffCommand; import com.graywolf336.jail.command.commands.UnJailForceCommand; import com.graywolf336.jail.command.commands.UnJailCommand; @@ -140,6 +141,7 @@ public class CommandHandler { /** Loads all the commands into the hashmap. */ private void loadCommands() { load(HandCuffCommand.class); + load(ToggleJailDebugCommand.class); load(UnHandCuffCommand.class); load(UnJailCommand.class); load(UnJailForceCommand.class); diff --git a/src/main/java/com/graywolf336/jail/command/commands/ToggleJailDebugCommand.java b/src/main/java/com/graywolf336/jail/command/commands/ToggleJailDebugCommand.java new file mode 100644 index 0000000..3739de5 --- /dev/null +++ b/src/main/java/com/graywolf336/jail/command/commands/ToggleJailDebugCommand.java @@ -0,0 +1,24 @@ +package com.graywolf336.jail.command.commands; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; + +import com.graywolf336.jail.JailManager; +import com.graywolf336.jail.command.Command; +import com.graywolf336.jail.command.CommandInfo; + +@CommandInfo( + maxArgs = 0, + minimumArgs = 0, + needsPlayer = false, + pattern = "togglejaildebug|tjd", + permission = "jail.command.toggledebug", + usage = "/togglejaildebug" + ) +public class ToggleJailDebugCommand implements Command { + public boolean execute(JailManager jm, CommandSender sender, String... args) { + boolean debug = jm.getPlugin().setDebugging(!jm.getPlugin().inDebug()); + sender.sendMessage("Jail debugging is now: " + (debug ? ChatColor.GREEN + "enabled" : ChatColor.RED + "disabled")); + return true; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c4bb4f3..77fe545 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -70,6 +70,8 @@ commands: description: Allows the player to handcuff another player unhandcuff: description: Allows the player to unhandcuff someone + togglejaildebug: + description: Toggles whether the plugin is in debugging state or not. permissions: jail.*: children: @@ -108,6 +110,7 @@ permissions: jail.command.jailreload: true jail.command.jailrecord: true jail.command.handcuff: true + jail.command.toggledebug: true jail.usercmd.*: description: access to all user commands children: @@ -191,4 +194,6 @@ permissions: jail.canswear: default: op jail.cantbejailed: + default: op + jail.command.toggledebug: default: op \ No newline at end of file