Skip to content

Commit

Permalink
implement core debug improvement
Browse files Browse the repository at this point in the history
also add an example in the meta for attributes
  • Loading branch information
mcmonkey4eva committed Aug 28, 2021
1 parent 70987e5 commit 647e9c2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Expand Up @@ -231,6 +231,7 @@ public void adjust(Mechanism mechanism) {
// Valid slots: HAND, OFF_HAND, FEET, LEGS, CHEST, HEAD, ANY
// Valid attribute names are listed at <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/attribute/Attribute.html>
// The default ID will be randomly generated, the default name will be the attribute name, the default slot is any.
// Example of valid input: [generic_max_health=<list[<map[operation=ADD_NUMBER;amount=20]>]>]
// @tags
// <EntityTag.has_attribute>
// <EntityTag.attribute_modifiers>
Expand Down
Expand Up @@ -127,6 +127,7 @@ public void adjust(Mechanism mechanism) {
// Valid slots: HAND, OFF_HAND, FEET, LEGS, CHEST, HEAD, ANY
// Valid attribute names are listed at <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/attribute/Attribute.html>
// The default ID will be randomly generated, the default name will be the attribute name, the default slot is any.
// Example of valid input: [generic_max_health=<list[<map[operation=ADD_NUMBER;amount=20;slot=HEAD]>]>]
// @tags
// <ItemTag.attribute_modifiers>
// -->
Expand Down
Expand Up @@ -164,16 +164,16 @@ public static void echoApproval(String message) {
}

public static void echoError(String message) {
echoError(null, message);
echoError(null, null, message, true);
}

public static void echoError(ScriptQueue sourceQueue, String message) {
echoError(sourceQueue, message, true);
echoError(sourceQueue, null, message, true);
}

public static boolean errorDuplicatePrevention = false;

public static void echoError(ScriptQueue sourceQueue, String message, boolean reformat) {
public static void echoError(ScriptQueue sourceQueue, String addedContext, String message, boolean reformat) {
message = cleanTextForDebugOutput(message);
if (errorDuplicatePrevention) {
if (!com.denizenscript.denizencore.utilities.debugging.Debug.verbose) {
Expand Down Expand Up @@ -225,12 +225,15 @@ else if (sourceQueue != null && sourceQueue.getEntries().size() > 0) {
}
BukkitScriptEntryData data = Utilities.getEntryData(sourceEntry);
if (data.hasPlayer()) {
fullMessage.append(" with player '").append(ChatColor.AQUA).append(data.getPlayer().debuggable()).append(ChatColor.RED).append("'");
fullMessage.append(" with player '").append(ChatColor.AQUA).append(data.getPlayer().getName()).append(ChatColor.RED).append("'");
}
if (data.hasNPC()) {
fullMessage.append(" with NPC '").append(ChatColor.AQUA).append(data.getNPC().debuggable()).append(ChatColor.RED).append("'");
}
}
if (addedContext != null) {
fullMessage.append("\n ").append(addedContext);
}
fullMessage.append("!\n").append(ChatColor.GRAY).append(" Error Message: ").append(ChatColor.WHITE).append(message);
if (sourceScript != null && !sourceScript.getContainer().shouldDebug()) {
fullMessage.append(ChatColor.GRAY).append(" ... ").append(ChatColor.RED).append("Enable debug on the script for more information.");
Expand Down Expand Up @@ -284,7 +287,7 @@ public static void echoError(ScriptQueue source, Throwable ex) {
}
else {
depthCorrectError++;
echoError(source, errorMessage, false);
echoError(source, null, errorMessage, false);
depthCorrectError--;
}
throwErrorEvent = wasThrown;
Expand Down Expand Up @@ -473,6 +476,7 @@ public static String cleanTextForDebugOutput(String message) {
.replace("<GR>", ChatColor.GREEN.toString())
.replace("<A>", ChatColor.AQUA.toString())
.replace("<R>", ChatColor.DARK_RED.toString())
.replace("<LR>", ChatColor.RED.toString())
.replace("<W>", ChatColor.WHITE.toString());
}

Expand Down
Expand Up @@ -76,13 +76,13 @@ public void debugException(Throwable ex) {
}

@Override
public void debugError(String error) {
Debug.echoError(error);
public void debugError(String addedContext, String error) {
Debug.echoError(null, addedContext, error, true);
}

@Override
public void debugError(ScriptQueue scriptQueue, String s) {
Debug.echoError(scriptQueue, s);
public void debugError(ScriptQueue scriptQueue, String addedContext, String s) {
Debug.echoError(scriptQueue, addedContext, s, true);
}

@Override
Expand Down

0 comments on commit 647e9c2

Please sign in to comment.