mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
Fix ANSI color codes not getting stripped on Paper (#4942)
Paper uses 0x7f as an intermediate character between adventure and its ANSI pattern converter, we need to strip this.
This commit is contained in:
parent
a7f602e2ad
commit
9147d1036d
@ -27,6 +27,7 @@ public final class FormatUtil {
|
|||||||
private static final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-zA-Z]{2,3}(?:/\\S+)?)");
|
private static final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-zA-Z]{2,3}(?:/\\S+)?)");
|
||||||
//Used to strip ANSI control codes from console
|
//Used to strip ANSI control codes from console
|
||||||
private static final Pattern ANSI_CONTROL_PATTERN = Pattern.compile("\u001B(?:\\[0?m|\\[38;2(?:;\\d{1,3}){3}m|\\[([0-9]{1,2}[;m]?){3})");
|
private static final Pattern ANSI_CONTROL_PATTERN = Pattern.compile("\u001B(?:\\[0?m|\\[38;2(?:;\\d{1,3}){3}m|\\[([0-9]{1,2}[;m]?){3})");
|
||||||
|
private static final Pattern PAPER_CONTROL_PATTERN = Pattern.compile("(?i)" + (char) 0x7f + "[0-9A-FK-ORX]");
|
||||||
|
|
||||||
private FormatUtil() {
|
private FormatUtil() {
|
||||||
}
|
}
|
||||||
@ -54,6 +55,13 @@ public final class FormatUtil {
|
|||||||
return stripColor(input, ANSI_CONTROL_PATTERN);
|
return stripColor(input, ANSI_CONTROL_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String stripPaper(final String input) {
|
||||||
|
if (input == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return stripColor(input, PAPER_CONTROL_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
//This is the general permission sensitive message format function, checks for urls.
|
//This is the general permission sensitive message format function, checks for urls.
|
||||||
public static String formatMessage(final IUser user, final String permBase, final String input) {
|
public static String formatMessage(final IUser user, final String permBase, final String input) {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
|
@ -62,8 +62,8 @@ public class ConsoleInjector extends AbstractAppender {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ansi strip is for normal colors, normal strip is for 1.16 hex color codes as they are not formatted correctly
|
// Ansi strip is for normal colors, normal strip is for 1.16 hex color codes as they are not formatted correctly, adventure strip is for magic color char strip
|
||||||
String entry = FormatUtil.stripFormat(FormatUtil.stripAnsi(event.getMessage().getFormattedMessage())).trim();
|
String entry = FormatUtil.stripPaper(FormatUtil.stripFormat(FormatUtil.stripAnsi(event.getMessage().getFormattedMessage()))).trim();
|
||||||
if (entry.isEmpty()) {
|
if (entry.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user