Highlight matched phrase.

master
Joey Hines 2020-09-20 17:49:37 -05:00
parent 0cc8568d67
commit d95a4b392f
3 changed files with 5 additions and 3 deletions

View File

@ -20,7 +20,7 @@ public class WatchList {
private static List<Pattern> buildPattern(List<String> patternList) { private static List<Pattern> buildPattern(List<String> patternList) {
return patternList return patternList
.stream() .stream()
.map(Pattern::compile) .map(p -> Pattern.compile(String.format("(%s)", p)))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }

View File

@ -73,9 +73,11 @@ public class HushAsyncChatListener implements Listener {
String playerName = player.getName(); String playerName = player.getName();
String webhook = plugin.getConfig().getString("webhook"); String webhook = plugin.getConfig().getString("webhook");
chatMessage = Javacord.escapeFormat(chatMessage);
chatMessage = pattern.matcher(chatMessage).replaceAll("**$0**");
if (webhook != null) { if (webhook != null) {
String message = playerName + " said: " + "`" + Javacord.escapeFormat(chatMessage) + "`"; String message = playerName + " said: " + chatMessage;
Embed embed = new Embed() Embed embed = new Embed()
.color(0xC70039) .color(0xC70039)
.description(message) .description(message)

View File

@ -1,5 +1,5 @@
name: Hush name: Hush
version: v0.1.0 version: 0.1.0
main: com.zerohighdef.hush.Hush main: com.zerohighdef.hush.Hush
api-version: "1.16" api-version: "1.16"
authors: [ZeroHighDef] authors: [ZeroHighDef]