Skip to content

Commit

Permalink
Add secret debugging flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Dec 15, 2013
1 parent 03e7911 commit 9624c8b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
Expand Up @@ -110,7 +110,9 @@ public static void removeDenizenRecipes() {
ItemScriptContainer.specialrecipesMap.clear();
}
catch (Throwable e) {
dB.echoError(e);
// Disable until bukkit fixes the issue, no sense worrying people about
// something we can't control.
// dB.echoError(e);
}
}

Expand Down
38 changes: 34 additions & 4 deletions src/main/java/net/aufdemrand/denizen/utilities/debugging/dB.java
Expand Up @@ -10,7 +10,10 @@

import net.aufdemrand.denizen.Settings;

import net.aufdemrand.denizen.flags.FlagManager;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.tags.TagManager;
import net.aufdemrand.denizen.utilities.Utilities;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -97,6 +100,23 @@ public static enum DebugElement {
//////


// <--[language]
// @Name 'show_command_reports' player flag
// @Group Useful flags

// @Description
// Giving a player the flag 'show_command_reports' will tell the Denizen dBugger to output
// command reports to the player involved with the ScriptEntry. This can be useful for
// script debugging, though it not an all-inclusive view of debugging information.
//
// To turn on and turn off the flag, just use:
// <code>
// /ex flag <player> show_command_reports
// /ex flag <player> show_command_reports:!
// </code>
//
// -->

/**
* Used by Commands to report how the supplied arguments were parsed.
* Should be supplied a concatenated String with aH.debugObject() or dObject.debug() of all
Expand All @@ -110,12 +130,22 @@ public static void report(Debuggable caller, String name, String report) {
if (!showDebug) return;
echo("<Y>+> <G>Executing '<Y>" + name + "<G>': "
+ trimMessage(report), caller);
}

if (caller instanceof ScriptEntry) {
if (((ScriptEntry) caller).hasPlayer()) {
if (FlagManager.playerHasFlag(((ScriptEntry) caller).getPlayer(), "show_command_reports")) {
String message = "<Y>+> <G>Executing '<Y>" + name + "<G>': "
+ trimMessage(report);

((ScriptEntry) caller).getPlayer().getPlayerEntity()
.sendRawMessage(message.replace("<Y>", ChatColor.YELLOW.toString())
.replace("<G>", ChatColor.DARK_GRAY.toString())
.replace("<A>", ChatColor.AQUA.toString()));
}
}
}
}

// Used by the various parts of Denizen that output debuggable information
// to help scripters see what is going on. Debugging an element is usually
// for formatting debug information.
public static void echoDebug(Debuggable caller, DebugElement element) {
if (!showDebug) return;
echoDebug(caller, element, null);
Expand Down

0 comments on commit 9624c8b

Please sign in to comment.