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 ff1c45e2e9..8ef956df8d 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 @@ -97,4 +97,15 @@ public interface ChatNotificationsConfig extends Config { return false; } + + @ConfigItem( + position = 6, + keyName = "notifyOnBroadcast", + name = "Notify on broadcast", + description = "Notifies you whenever you receive a broadcast message" + ) + default boolean notifyOnBroadcast() + { + return false; + } } 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 f4dcab1ea5..dc663ca462 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 @@ -144,6 +144,22 @@ public class ChatNotificationsPlugin extends Plugin notifier.notify(chatMessage.getMessage()); } break; + case BROADCAST: + if (config.notifyOnBroadcast()) + { + // Some broadcasts have links attached, notated by `|` followed by a number, while others contain color tags. + // We don't want to see either in the printed notification. + String broadcast = chatMessage.getMessage(); + + int urlTokenIndex = broadcast.lastIndexOf('|'); + if (urlTokenIndex != -1) + { + broadcast = broadcast.substring(0, urlTokenIndex); + } + + notifier.notify(Text.removeFormattingTags(broadcast)); + } + break; case CONSOLE: // Don't notify for notification messages if (chatMessage.getName().equals(RuneLiteProperties.getTitle()))