From 7f27de4bb7c460af9f7c1fe1fd24f9f87e2427e0 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 19 Aug 2013 21:28:05 +0100 Subject: Fix text file color code escaping (&&6 -> &6) Add support for color escaping in ingame chat Other formatting class cleanup --- .../com/earth2me/essentials/utils/FormatUtil.java | 50 ++++++++++++---------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java b/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java index 9d3ef7cb0..82f106ac9 100644 --- a/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java @@ -6,15 +6,19 @@ import java.util.regex.Pattern; public class FormatUtil { - static final transient Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-fA-F])"); + //Vanilla patterns used to strip existing formats + static final transient Pattern VANILLA_PATTERN = Pattern.compile("\u00a7+[0-9A-FK-ORa-fk-or]?"); + static final transient Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00a7+[0-9A-Fa-f]"); static final transient Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00a7+[Kk]"); static final transient Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00a7+[L-ORl-or]"); - static final transient Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-orL-OR])"); - static final transient Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&([Kk])"); - static final transient Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-orA-FK-OR])"); + //Essentials '&' convention colour codes + static final transient Pattern REPLACE_ALL_PATTERN = Pattern.compile("(?