mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
1 parent
d9986ac035
commit
adb7f0d836
1 file changed
+32
-33
+32
-33
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2020.
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -62,6 +62,7 @@ import java.util.List;
|
||||
@PerformanceSensitive("allocation")
|
||||
public class MinecraftFormattingConverter extends LogEventPatternConverter
|
||||
{
|
||||
|
||||
/**
|
||||
* System property that allows disabling the replacement of Minecraft
|
||||
* formatting codes entirely, keeping them in the console output. For
|
||||
@@ -76,34 +77,34 @@ public class MinecraftFormattingConverter extends LogEventPatternConverter
|
||||
|
||||
private static final boolean KEEP_FORMATTING = PropertiesUtil.getProperties().getBooleanProperty(KEEP_FORMATTING_PROPERTY);
|
||||
|
||||
private static final String ANSI_RESET = "\u001B[39;0m";
|
||||
private static final String ANSI_RESET = "\u001B[m";
|
||||
|
||||
private static final char COLOR_CHAR = '\u00A7'; // §
|
||||
private static final String LOOKUP = "0123456789abcdefklmnor";
|
||||
|
||||
private static final String[] ansiCodes = new String[] {
|
||||
"\u001B[0;30;22m", // Black §0
|
||||
"\u001B[0;34;22m", // Dark Blue §1
|
||||
"\u001B[0;32;22m", // Dark Green §2
|
||||
"\u001B[0;36;22m", // Dark Aqua §3
|
||||
"\u001B[0;31;22m", // Dark Red §4
|
||||
"\u001B[0;35;22m", // Dark Purple §5
|
||||
"\u001B[0;33;22m", // Gold §6
|
||||
"\u001B[0;37;22m", // 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[21m", // Bold §l
|
||||
"\u001B[9m", // Strikethrough §m
|
||||
"\u001B[4m", // Underline §n
|
||||
"\u001B[3m", // Italic §o
|
||||
ANSI_RESET, // Reset §r
|
||||
"\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[21m", // Bold §l
|
||||
"\u001B[9m", // Strikethrough §m
|
||||
"\u001B[4m", // Underline §n
|
||||
"\u001B[3m", // Italic §o
|
||||
ANSI_RESET, // Reset §r
|
||||
};
|
||||
|
||||
private final boolean ansi;
|
||||
@@ -154,16 +155,15 @@ public class MinecraftFormattingConverter extends LogEventPatternConverter
|
||||
result.setLength(start + next);
|
||||
|
||||
int pos = next;
|
||||
int format;
|
||||
do {
|
||||
if (pos != next)
|
||||
{
|
||||
result.append(s, pos, next);
|
||||
}
|
||||
|
||||
format = LOOKUP.indexOf(s.charAt(next + 1));
|
||||
do
|
||||
{
|
||||
int format = LOOKUP.indexOf(Character.toLowerCase(s.charAt(next + 1)));
|
||||
if (format != -1)
|
||||
{
|
||||
if (pos != next)
|
||||
{
|
||||
result.append(s, pos, next);
|
||||
}
|
||||
if (ansi)
|
||||
{
|
||||
result.append(ansiCodes[format]);
|
||||
@@ -214,5 +214,4 @@ public class MinecraftFormattingConverter extends LogEventPatternConverter
|
||||
boolean strip = options.length > 1 && "strip".equals(options[1]);
|
||||
return new MinecraftFormattingConverter(formatters, strip);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user