mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
Handle legacy quirk in the console formatter (#8434)
This commit is contained in:
parent
309133e2e1
commit
8796175d79
1 changed files with 26 additions and 25 deletions
|
@ -65,10 +65,10 @@ index c3631efda9c7fa531a8a9f18fbee7b5f8655382b..9a3c1314d5a0aa20380662595359580b
|
|||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/console/HexFormattingConverter.java b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b4d0b7ecd56ab952319946854168c1299cb0b1be
|
||||
index 0000000000000000000000000000000000000000..b9922b07cb105618390187d98acdf89e728e1f5a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java
|
||||
@@ -0,0 +1,212 @@
|
||||
@@ -0,0 +1,213 @@
|
||||
+package io.papermc.paper.console;
|
||||
+
|
||||
+import io.papermc.paper.configuration.GlobalConfiguration;
|
||||
|
@ -117,6 +117,7 @@ index 0000000000000000000000000000000000000000..b4d0b7ecd56ab952319946854168c129
|
|||
+ private static final String LOOKUP = "0123456789abcdefklmnor";
|
||||
+
|
||||
+ private static final String RGB_ANSI = "\u001B[38;2;%d;%d;%dm";
|
||||
+ private static final String RESET_RGB_ANSI = ANSI_RESET + RGB_ANSI;
|
||||
+ private static final Pattern NAMED_PATTERN = Pattern.compile(COLOR_CHAR + "[0-9a-fk-orA-FK-OR]");
|
||||
+ private static final Pattern RGB_PATTERN = Pattern.compile(COLOR_CHAR + "#([0-9a-fA-F]){6}");
|
||||
+
|
||||
|
@ -145,28 +146,28 @@ index 0000000000000000000000000000000000000000..b4d0b7ecd56ab952319946854168c129
|
|||
+ ANSI_RESET, // Reset §r
|
||||
+ };
|
||||
+ private static final String[] ANSI_ANSI_CODES = new String[]{
|
||||
+ "\u001B[0;30m", // Black §0
|
||||
+ "\u001B[0;34m", // Dark Blue §1
|
||||
+ "\u001B[0;32m", // Dark Green §2
|
||||
+ "\u001B[0;36m", // Dark Aqua §3
|
||||
+ "\u001B[0;31m", // Dark Red §4
|
||||
+ "\u001B[0;35m", // Dark Purple §5
|
||||
+ "\u001B[0;33m", // Gold §6
|
||||
+ "\u001B[0;37m", // Gray §7
|
||||
+ "\u001B[0;30;1m", // Dark Gray §8
|
||||
+ "\u001B[0;34;1m", // Blue §9
|
||||
+ "\u001B[0;32;1m", // Green §a
|
||||
+ "\u001B[0;36;1m", // Aqua §b
|
||||
+ "\u001B[0;31;1m", // Red §c
|
||||
+ "\u001B[0;35;1m", // Light Purple §d
|
||||
+ "\u001B[0;33;1m", // Yellow §e
|
||||
+ "\u001B[0;37;1m", // White §f
|
||||
+ "\u001B[5m", // Obfuscated §k
|
||||
+ "\u001B[1m", // Bold §l
|
||||
+ "\u001B[9m", // Strikethrough §m
|
||||
+ "\u001B[4m", // Underline §n
|
||||
+ "\u001B[3m", // Italic §o
|
||||
+ ANSI_RESET, // Reset §r
|
||||
+ ANSI_RESET + "\u001B[0;30m", // Black §0
|
||||
+ ANSI_RESET + "\u001B[0;34m", // Dark Blue §1
|
||||
+ ANSI_RESET + "\u001B[0;32m", // Dark Green §2
|
||||
+ ANSI_RESET + "\u001B[0;36m", // Dark Aqua §3
|
||||
+ ANSI_RESET + "\u001B[0;31m", // Dark Red §4
|
||||
+ ANSI_RESET + "\u001B[0;35m", // Dark Purple §5
|
||||
+ ANSI_RESET + "\u001B[0;33m", // Gold §6
|
||||
+ ANSI_RESET + "\u001B[0;37m", // Gray §7
|
||||
+ ANSI_RESET + "\u001B[0;30;1m", // Dark Gray §8
|
||||
+ ANSI_RESET + "\u001B[0;34;1m", // Blue §9
|
||||
+ ANSI_RESET + "\u001B[0;32;1m", // Green §a
|
||||
+ ANSI_RESET + "\u001B[0;36;1m", // Aqua §b
|
||||
+ ANSI_RESET + "\u001B[0;31;1m", // Red §c
|
||||
+ ANSI_RESET + "\u001B[0;35;1m", // Light Purple §d
|
||||
+ ANSI_RESET + "\u001B[0;33;1m", // Yellow §e
|
||||
+ ANSI_RESET + "\u001B[0;37;1m", // White §f
|
||||
+ "\u001B[5m", // Obfuscated §k
|
||||
+ "\u001B[1m", // Bold §l
|
||||
+ "\u001B[9m", // Strikethrough §m
|
||||
+ "\u001B[4m", // Underline §n
|
||||
+ "\u001B[3m", // Italic §o
|
||||
+ ANSI_RESET, // Reset §r
|
||||
+ };
|
||||
+
|
||||
+ private final boolean ansi;
|
||||
|
@ -218,7 +219,7 @@ index 0000000000000000000000000000000000000000..b4d0b7ecd56ab952319946854168c129
|
|||
+ final int red = color >> 16 & 0xFF;
|
||||
+ final int green = color >> 8 & 0xFF;
|
||||
+ final int blue = color & 0xFF;
|
||||
+ return String.format(RGB_ANSI, red, green, blue);
|
||||
+ return String.format(RESET_RGB_ANSI, red, green, blue);
|
||||
+ }
|
||||
+
|
||||
+ private static String stripRGBColors(final String input) {
|
||||
|
|
Loading…
Reference in a new issue