From d95a4b392f15f97291ed68ef67cee8eb3b8bb5b1 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Sun, 20 Sep 2020 17:49:37 -0500 Subject: [PATCH] Highlight matched phrase. --- src/main/java/com/zerohighdef/hush/WatchList.java | 2 +- .../com/zerohighdef/hush/listeners/HushAsyncChatListener.java | 4 +++- src/main/resources/plugin.yml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zerohighdef/hush/WatchList.java b/src/main/java/com/zerohighdef/hush/WatchList.java index 523dfd4..703b34b 100644 --- a/src/main/java/com/zerohighdef/hush/WatchList.java +++ b/src/main/java/com/zerohighdef/hush/WatchList.java @@ -20,7 +20,7 @@ public class WatchList { private static List buildPattern(List patternList) { return patternList .stream() - .map(Pattern::compile) + .map(p -> Pattern.compile(String.format("(%s)", p))) .collect(Collectors.toList()); } diff --git a/src/main/java/com/zerohighdef/hush/listeners/HushAsyncChatListener.java b/src/main/java/com/zerohighdef/hush/listeners/HushAsyncChatListener.java index 0cd399c..9ff7b4e 100644 --- a/src/main/java/com/zerohighdef/hush/listeners/HushAsyncChatListener.java +++ b/src/main/java/com/zerohighdef/hush/listeners/HushAsyncChatListener.java @@ -73,9 +73,11 @@ public class HushAsyncChatListener implements Listener { String playerName = player.getName(); String webhook = plugin.getConfig().getString("webhook"); + chatMessage = Javacord.escapeFormat(chatMessage); + chatMessage = pattern.matcher(chatMessage).replaceAll("**$0**"); if (webhook != null) { - String message = playerName + " said: " + "`" + Javacord.escapeFormat(chatMessage) + "`"; + String message = playerName + " said: " + chatMessage; Embed embed = new Embed() .color(0xC70039) .description(message) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 62e74c2..5fb964f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: Hush -version: v0.1.0 +version: 0.1.0 main: com.zerohighdef.hush.Hush api-version: "1.16" authors: [ZeroHighDef]