Skip to content

Commit

Permalink
cleanups and improvements to debug recording internal
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 4, 2021
1 parent 8745a42 commit 8564ec9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Expand Up @@ -249,7 +249,7 @@ public static String cleanRedundantCodes(String str) {
while (index != -1) {
output.append(str, start, index);
start = index;
if (index + 1 > str.length()) {
if (index + 1 >= str.length()) {
break;
}
char symbol = str.charAt(index + 1);
Expand Down
Expand Up @@ -556,8 +556,12 @@ public static void sendMessage(String string, boolean reformat) {

// Record current buffer to the to-be-submitted buffer
if (Debug.record) {
Debug.recording.append(URLEncoder.encode(dateFormat.format(new Date())
+ " [INFO] " + string.replace(ChatColor.COLOR_CHAR, (char) 0x01) + "\n"));
try {
Debug.recording.append(URLEncoder.encode(dateFormat.format(new Date()) + string + "\n", "UTF-8"));
}
catch (Throwable ex) {
Debug.echoError(ex);
}
}
string = Settings.debugPrefix() + string;
if (DenizenCore.logInterceptor.redirected) {
Expand Down
Expand Up @@ -32,6 +32,7 @@ public void run() {
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setConnectTimeout(10000);
uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
uc.connect();
// Safely connected at this point
// Build a list of plugins
Expand Down Expand Up @@ -65,7 +66,7 @@ public void run() {
newlineLength = 0;
int playerCount = Bukkit.getOnlinePlayers().size();
for (Player pla : Bukkit.getOnlinePlayers()) {
String temp = pla.getDisplayName().replace(ChatColor.COLOR_CHAR, (char) 0x01) + ((char) 0x01) + "7(" + pla.getName() + "), ";
String temp = pla.getDisplayName() + ChatColor.GRAY + "(" + pla.getName() + "), ";
playerlist.append(temp);
newlineLength += temp.length();
if (newlineLength > 80) {
Expand Down Expand Up @@ -96,7 +97,7 @@ public void run() {
// Create the final message pack and upload it
uc.getOutputStream().write(("pastetype=log"
+ "&response=micro&v=200&pastetitle=Denizen+Debug+Logs+From+" + URLEncoder.encode(ChatColor.stripColor(Bukkit.getServer().getMotd()))
+ "&pastecontents=" + URLEncoder.encode(("Java Version: " + System.getProperty("java.version")
+ "&pastecontents=" + URLEncoder.encode("Java Version: " + System.getProperty("java.version")
+ "\nUp-time: " + new DurationTag((System.currentTimeMillis() - DenizenCore.startTime) / 50).formatted(false)
+ "\nServer Version: " + Bukkit.getServer().getName() + " version " + Bukkit.getServer().getVersion()
+ "\nDenizen Version: Core: " + DenizenCore.VERSION + ", CraftBukkit: " + Denizen.getInstance().coreImplementation.getImplementationVersion()
Expand All @@ -106,12 +107,15 @@ public void run() {
+ "\nTotal Players Ever: " + PlayerTag.getAllPlayers().size() + " (" + validPl + " valid, " + invalidPl + " invalid)"
+ "\nMode: " + (Bukkit.getServer().getOnlineMode() ? ChatColor.GREEN + "online" : (bungee ? ChatColor.YELLOW : ChatColor.RED) + "offline") + (bungee ? " (BungeeCord)" : "")
+ "\nLast reload: " + new DurationTag((System.currentTimeMillis() - DenizenCore.lastReloadTime) / 1000.0).formatted(false) + " ago"
+ "\n\n").replace(ChatColor.COLOR_CHAR, (char) 0x01)) + recording)
+ "\n\n", "UTF-8") + recording)
.getBytes(StandardCharsets.UTF_8));
// Wait for a response from the server
in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
// Record the response
result = in.readLine();
if (result != null && result.startsWith(("<!DOCTYPE html"))) {
result = null;
}
// Close the connection
in.close();
}
Expand Down
Expand Up @@ -444,12 +444,7 @@ public void submitRecording(Consumer<String> processResult) {
public void run() {
if (!submit.isAlive()) {
this.cancel();
if (submit.result == null) {
processResult.accept(null);
}
else {
processResult.accept(submit.result);
}
processResult.accept(submit.result);
}
}
};
Expand Down

0 comments on commit 8564ec9

Please sign in to comment.