mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-02 04:40:55 +02:00
Strip colors from chat, if the user does not have the permission.
This commit is contained in:
@@ -478,7 +478,7 @@ public class Util
|
|||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
private static transient final Pattern COLOR_PATTERN = Pattern.compile("(?i)\u00A7[0-9A-F]");
|
private static transient final Pattern COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
|
||||||
|
|
||||||
public static String stripColor(final String input)
|
public static String stripColor(final String input)
|
||||||
{
|
{
|
||||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.chat;
|
|||||||
|
|
||||||
import com.earth2me.essentials.IEssentials;
|
import com.earth2me.essentials.IEssentials;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@@ -32,6 +33,8 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
|
|||||||
if (user.isAuthorized("essentials.chat.color"))
|
if (user.isAuthorized("essentials.chat.color"))
|
||||||
{
|
{
|
||||||
event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "\u00a7$1"));
|
event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "\u00a7$1"));
|
||||||
|
} else {
|
||||||
|
event.setMessage(Util.stripColor(event.getMessage()));
|
||||||
}
|
}
|
||||||
event.setFormat(ess.getSettings().getChatFormat(user.getGroup()).replace('&', '\u00a7').replace("\u00a7\u00a7", "&").replace("{DISPLAYNAME}", "%1$s").replace("{GROUP}", user.getGroup()).replace("{MESSAGE}", "%2$s").replace("{WORLDNAME}", user.getWorld().getName()).replace("{SHORTWORLDNAME}", user.getWorld().getName().substring(0, 1).toUpperCase(Locale.ENGLISH)));
|
event.setFormat(ess.getSettings().getChatFormat(user.getGroup()).replace('&', '\u00a7').replace("\u00a7\u00a7", "&").replace("{DISPLAYNAME}", "%1$s").replace("{GROUP}", user.getGroup()).replace("{MESSAGE}", "%2$s").replace("{WORLDNAME}", user.getWorld().getName()).replace("{SHORTWORLDNAME}", user.getWorld().getName().substring(0, 1).toUpperCase(Locale.ENGLISH)));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user