mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 04:23:02 +00:00
Compiled regex is faster.
This commit is contained in:
parent
36bc1adf83
commit
a10f6850e5
5 changed files with 19 additions and 8 deletions
|
@ -478,7 +478,8 @@ public class Util
|
|||
}
|
||||
return buf.toString();
|
||||
}
|
||||
private static transient final Pattern COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
|
||||
private static transient final Pattern EASY_COLOR_PATTERN = Pattern.compile("&([0-9a-fk])");
|
||||
|
||||
public static String stripColor(final String input)
|
||||
{
|
||||
|
@ -487,6 +488,16 @@ public class Util
|
|||
return null;
|
||||
}
|
||||
|
||||
return COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String replaceColor(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return EASY_COLOR_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue