Skip to content

Commit

Permalink
Reduce Debug recording lag
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 21, 2013
1 parent df2cbfc commit 87b4c51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
Expand Up @@ -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 <item>)
//
// @Triggers when a player right clicks on an entity.
// @Context
Expand Down
25 changes: 7 additions & 18 deletions src/main/java/net/aufdemrand/denizen/utilities/debugging/dB.java
Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 87b4c51

Please sign in to comment.