Merge pull request 'Highlight matched phrase.' (#1) from ZeroHD/Hush:master into master

Reviewed-on: https://git.etztech.xyz/Minecraft/Hush/pulls/1
master
Joey Hines 2020-09-21 00:50:29 +02:00
commit 7746f6905e
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]