forked from Minecraft/QoL
Add escape for Discord syntax (#41)
parent
6d73df72a3
commit
ee0867d5cc
|
@ -45,6 +45,20 @@ public class AsyncPlayerChatListener implements Listener {
|
||||||
// Discord syntax for font emphasis
|
// Discord syntax for font emphasis
|
||||||
if (player.hasPermission("qol.discord")) {
|
if (player.hasPermission("qol.discord")) {
|
||||||
String chat = event.getMessage();
|
String chat = event.getMessage();
|
||||||
|
boolean escape = false;
|
||||||
|
|
||||||
|
// Escape
|
||||||
|
if (chat.startsWith("\\")) {
|
||||||
|
escape = true;
|
||||||
|
event.setMessage(chat.substring(1));
|
||||||
|
|
||||||
|
// Escape the escape, this monster wants to start their message with a backslash
|
||||||
|
if (chat.startsWith("\\\\")) {
|
||||||
|
escape = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!escape) {
|
||||||
Pattern syntax;
|
Pattern syntax;
|
||||||
Matcher matcher;
|
Matcher matcher;
|
||||||
for (int i = 0; i < discordSyntax.size(); i++) {
|
for (int i = 0; i < discordSyntax.size(); i++) {
|
||||||
|
@ -71,6 +85,7 @@ public class AsyncPlayerChatListener implements Listener {
|
||||||
event.setMessage(ChatColor.translateAlternateColorCodes('&', chat));
|
event.setMessage(ChatColor.translateAlternateColorCodes('&', chat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue