mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
Compiled regex is faster.
This commit is contained in:
parent
36bc1adf83
commit
a10f6850e5
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class Commandme extends EssentialsCommand
|
||||
String message = getFinalArg(args, 0);
|
||||
if (user.isAuthorized("essentials.chat.color"))
|
||||
{
|
||||
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else {
|
||||
message = Util.stripColor(message);
|
||||
|
@ -36,7 +36,7 @@ public class Commandmsg extends EssentialsCommand
|
||||
}
|
||||
if (user.isAuthorized("essentials.msg.color"))
|
||||
{
|
||||
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -45,7 +45,7 @@ public class Commandmsg extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
|
||||
final String translatedMe = _("me");
|
||||
|
@ -34,7 +34,7 @@ public class Commandr extends EssentialsCommand
|
||||
User user = ess.getUser(sender);
|
||||
if (user.isAuthorized("essentials.msg.color"))
|
||||
{
|
||||
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -45,7 +45,7 @@ public class Commandr extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||
message = Util.replaceColor(message);
|
||||
replyTo = Console.getConsoleReplyTo();
|
||||
senderName = Console.NAME;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
|
||||
*/
|
||||
if (user.isAuthorized("essentials.chat.color"))
|
||||
{
|
||||
event.setMessage(event.getMessage().replaceAll("&([0-9a-fk])", "\u00a7$1"));
|
||||
event.setMessage(Util.replaceColor(event.getMessage()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user