From 6111a4b790bc77e2a343029dd42eec0adbc8be75 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 2 Jul 2020 00:36:38 -0400 Subject: [PATCH] chatnotifications: Only notify on name in player messages (#11874) This commit changes the behavior of notifyOnOwnName so that it only notifies the user when their name is mentioned in a chat message sent by another player to prevent notification spam during PVM and other activities. --- .../chatnotifications/ChatNotificationsConfig.java | 2 +- .../chatnotifications/ChatNotificationsPlugin.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsConfig.java index 8ef956df8d..80044fc340 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsConfig.java @@ -58,7 +58,7 @@ public interface ChatNotificationsConfig extends Config position = 2, keyName = "notifyOnOwnName", name = "Notify on own name", - description = "Notifies you whenever your name is mentioned" + description = "Notifies you whenever someone mentions you by name" ) default boolean notifyOnOwnName() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java index dc663ca462..a412756fa1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java @@ -34,6 +34,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.inject.Inject; +import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.MessageNode; import net.runelite.api.events.ChatMessage; @@ -186,8 +187,11 @@ public class ChatNotificationsPlugin extends Plugin { messageNode.setValue(matcher.replaceAll(usernameReplacer)); update = true; - - if (config.notifyOnOwnName()) + if (config.notifyOnOwnName() && (chatMessage.getType() == ChatMessageType.PUBLICCHAT + || chatMessage.getType() == ChatMessageType.PRIVATECHAT + || chatMessage.getType() == ChatMessageType.FRIENDSCHAT + || chatMessage.getType() == ChatMessageType.MODCHAT + || chatMessage.getType() == ChatMessageType.MODPRIVATECHAT)) { sendNotification(chatMessage); }