3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-14 20:10:05 +01:00

Strip colours from logs when enabled.

Dieser Commit ist enthalten in:
md_5 2013-03-15 20:46:16 +11:00
Ursprung b8d6b349b9
Commit 71978f3a0e

Datei anzeigen

@ -1,16 +1,16 @@
From 5c0b24378261fd1b5dc1c0911b77a974f7395e70 Mon Sep 17 00:00:00 2001
From 45cd8d3b26d64220cfb86dac4a07416b2919c5f1 Mon Sep 17 00:00:00 2001
From: James Clarke <jamesrtclarke@me.com>
Date: Sat, 26 Jan 2013 10:39:45 +0000
Subject: [PATCH] ANSI color codes now reset text attributes. Fixes BUKKIT-3508
The client resets all formatting after a color code is received, but currently the ANSI codes do not, and so the console does not accurately reflect the appearance of the formatted text. Instead, the ANSI color codes are now set to reset all text attributes.
---
.../net/minecraft/server/ConsoleLogFormatter.java | 3 +-
.../net/minecraft/server/ConsoleLogFormatter.java | 9 ++++--
.../craftbukkit/command/ColouredConsoleSender.java | 34 +++++++++++-----------
2 files changed, 18 insertions(+), 19 deletions(-)
2 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/src/main/java/net/minecraft/server/ConsoleLogFormatter.java b/src/main/java/net/minecraft/server/ConsoleLogFormatter.java
index 6a58493..6575ea7 100644
index 6a58493..e945f7a 100644
--- a/src/main/java/net/minecraft/server/ConsoleLogFormatter.java
+++ b/src/main/java/net/minecraft/server/ConsoleLogFormatter.java
@@ -13,7 +13,6 @@ final class ConsoleLogFormatter extends Formatter {
@ -21,12 +21,18 @@ index 6a58493..6575ea7 100644
private boolean strip = false;
ConsoleLogFormatter(boolean strip) {
@@ -56,7 +55,7 @@ final class ConsoleLogFormatter extends Formatter {
@@ -56,7 +55,13 @@ final class ConsoleLogFormatter extends Formatter {
// CraftBukkit start - handle stripping color
if (this.strip) {
- return this.pattern.matcher(stringbuilder.toString()).replaceAll("");
+ return org.bukkit.ChatColor.stripColor(stringbuilder.toString());
+ StringBuilder line = new StringBuilder();
+ for (char c : stringbuilder.toString().toCharArray()) {
+ if (Character.isLetterOrDigit(c)) {
+ line.append(c);
+ }
+ }
+ return line.toString();
} else {
return stringbuilder.toString();
}