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.
This commit is contained in:
Broooklyn
2020-07-02 00:36:38 -04:00
committed by GitHub
parent b1beeed188
commit 6111a4b790
2 changed files with 7 additions and 3 deletions

View File

@@ -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()
{

View File

@@ -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);
}