improve ping regex

This commit is contained in:
Jason Penilla committed 2023-07-10 11:42:43 -07:00
1 parent 141772f72e
commit d05cc65258
1 file changed
+7 -1
@@ -82,7 +82,13 @@ public class PingHandler implements Listener {
return message.replaceText(TextReplacementConfig.builder()
// \B(@Username|@Displayname)\b
.match(Pattern.compile(String.format("\\B%1$s(%2$s|%3$s)\\b", prefix, recipient.username(), displayName), Pattern.CASE_INSENSITIVE))
.match(Pattern.compile(
String.format(
"\\B%1$s(%2$s|%3$s)\\b",
Pattern.quote(prefix),
Pattern.quote(recipient.username()),
Pattern.quote(displayName)),
Pattern.CASE_INSENSITIVE))
.replacement(matchedText -> {
if (this.configFactory.primaryConfig().pings().playSound()) {
recipient.playSound(this.configFactory.primaryConfig().pings().sound());