From 87b4c5134c1a1b9843d9e130178342d41a986b99 Mon Sep 17 00:00:00 2001 From: mcmonkey4eva Date: Mon, 21 Oct 2013 16:15:02 -0700 Subject: [PATCH] Reduce Debug recording lag --- .../containers/core/WorldScriptHelper.java | 2 +- .../denizen/utilities/debugging/dB.java | 25 ++++++------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/containers/core/WorldScriptHelper.java b/src/main/java/net/aufdemrand/denizen/scripts/containers/core/WorldScriptHelper.java index 91b173bd67..eb08c27f08 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/containers/core/WorldScriptHelper.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/containers/core/WorldScriptHelper.java @@ -3427,7 +3427,7 @@ else if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) // <--[event] // @Events - // player right clicks entity (with item) + // player right clicks entity (with ) // // @Triggers when a player right clicks on an entity. // @Context diff --git a/src/main/java/net/aufdemrand/denizen/utilities/debugging/dB.java b/src/main/java/net/aufdemrand/denizen/utilities/debugging/dB.java index 7fc6235910..b47c5b0b79 100644 --- a/src/main/java/net/aufdemrand/denizen/utilities/debugging/dB.java +++ b/src/main/java/net/aufdemrand/denizen/utilities/debugging/dB.java @@ -7,7 +7,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.net.URLEncoder; -import java.util.Calendar; +import java.text.SimpleDateFormat; +import java.util.Date; /** * Preferred method of outputting debugger information with Denizen and @@ -106,6 +107,7 @@ private static class ConsoleSender { // Bukkit CommandSender sends color nicely to the logger. static CommandSender commandSender = null; static boolean skipFooter = false; + static SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); public static void sendMessage(String string) { if (commandSender == null) commandSender = Bukkit.getServer().getConsoleSender(); @@ -135,27 +137,14 @@ public static void sendMessage(String string) { buffer = buffer + "\n" + " " + word + " "; } // 16:05:06 [INFO] } + + // Record current buffer to the to-be-submitted buffer + if (dB.record) dB.Recording += URLEncoder.encode(dateFormat.format(new Date()) + " [INFO] " + buffer.replace(ChatColor.COLOR_CHAR, (char)0x01) + "\n"); + // Send buffer to the player - dB.Recording += URLEncoder.encode(getDate() + " [INFO] " + buffer.replace(ChatColor.COLOR_CHAR, (char)0x01) + "\n"); if (showColor) commandSender.sendMessage(buffer); else commandSender.sendMessage(ChatColor.stripColor(buffer)); - - - } - - static String getDate() { - Calendar calendar = Calendar.getInstance(); - int h = calendar.get(Calendar.HOUR_OF_DAY); - int m = calendar.get(Calendar.MINUTE); - int s = calendar.get(Calendar.SECOND); - String toret = ""; - if (h < 10) toret += "0" + h; else toret += h; - toret += ":"; - if (m < 10) toret += "0" + m; else toret += m; - toret += ":"; - if (s < 10) toret += "0" + s; else toret += s; - return toret; } }