Use Bukkit ChatColor instead of ess regex to strip colors.

This commit is contained in:
drtshock 2015-07-23 15:23:23 -05:00
parent 28607ce58c
commit d5301824fc
2 changed files with 4 additions and 3 deletions

View File

@ -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));
}
}
}

View File

@ -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