From d5301824fcef59bf410349cb1e22574b92a252ee Mon Sep 17 00:00:00 2001 From: drtshock Date: Thu, 23 Jul 2015 15:23:23 -0500 Subject: [PATCH] Use Bukkit ChatColor instead of ess regex to strip colors. --- .../src/com/earth2me/essentials/signs/SignBlockListener.java | 3 ++- Essentials/src/com/earth2me/essentials/utils/FormatUtil.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 02bd6b6b2..c2760470b 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.User; import com.earth2me.essentials.utils.FormatUtil; import net.ess3.api.IEssentials; import net.ess3.api.MaxMoneyException; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; @@ -86,7 +87,7 @@ public class SignBlockListener implements Listener { for (Signs signs : Signs.values()) { final EssentialsSign sign = signs.getSign(); if (topLine.equalsIgnoreCase(sign.getSuccessName())) { - event.setLine(0, FormatUtil.stripFormat(topLine)); + event.setLine(0, ChatColor.stripColor(topLine)); } } } diff --git a/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java b/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java index 46cc3509e..001a1daec 100644 --- a/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java @@ -1,13 +1,13 @@ package com.earth2me.essentials.utils; import net.ess3.api.IUser; +import org.bukkit.ChatColor; import java.util.regex.Pattern; public class FormatUtil { //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]"); @@ -27,7 +27,7 @@ public class FormatUtil { if (input == null) { return null; } - return stripColor(input, VANILLA_PATTERN); + return ChatColor.stripColor(input); } //This method is used to simply strip the & convention colour codes