net.runelite.api.events.ChatMessage Java Examples
The following examples show how to use
net.runelite.api.events.ChatMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmojiPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testOnChatMessage() { when(client.getGameState()).thenReturn(GameState.LOGGED_IN); when(client.getModIcons()).thenReturn(new IndexedSprite[0]); when(client.createIndexedSprite()).thenReturn(mock(IndexedSprite.class)); // Trip emoji loading GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGGED_IN); emojiPlugin.onGameStateChanged(gameStateChanged); MessageNode messageNode = mock(MessageNode.class); // With chat recolor, message may be wrapped in col tags when(messageNode.getValue()).thenReturn("<col=ff0000>:) :) :)</col>"); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setMessageNode(messageNode); emojiPlugin.onChatMessage(chatMessage); verify(messageNode).setRuneLiteFormatMessage("<col=ff0000><img=0> <img=0> <img=0></col>"); }
Example #2
Source File: EmojiPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testGtLt() { when(client.getGameState()).thenReturn(GameState.LOGGED_IN); when(client.getModIcons()).thenReturn(new IndexedSprite[0]); when(client.createIndexedSprite()).thenReturn(mock(IndexedSprite.class)); // Trip emoji loading GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGGED_IN); emojiPlugin.onGameStateChanged(gameStateChanged); MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn("<gt>:D<lt>"); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setMessageNode(messageNode); emojiPlugin.onChatMessage(chatMessage); verify(messageNode).setRuneLiteFormatMessage("<img=10>"); }
Example #3
Source File: ChatNotificationsPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testPreceedingColor() { when(config.highlightWordsString()).thenReturn("you. It"); String message = "Your dodgy <col=00ff00>necklace protects you. It has 1 charge left.</col>"; MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn(message); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setMessageNode(messageNode); chatNotificationsPlugin.startUp(); // load highlight config chatNotificationsPlugin.onChatMessage(chatMessage); verify(messageNode).setValue("Your dodgy <col=00ff00>necklace protects <colHIGHLIGHT>you. It<col=00ff00> has 1 charge left.</col>"); }
Example #4
Source File: SmeltingPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SPAM) { return; } if (event.getMessage().startsWith("You retrieve a bar of")) { if (session == null) { session = new SmeltingSession(); } session.increaseBarsSmelted(); } else if (event.getMessage().startsWith("You remove the cannonballs from the mould")) { if (session == null) { session = new SmeltingSession(); } session.increaseCannonBallsSmelted(); } }
Example #5
Source File: BasicBossSwapper.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (!run || event.getType() != ChatMessageType.GAMEMESSAGE) { return; } String msg = Text.standardize(event.getMessage()); if (msg.startsWith(MAGE)) { swapMage = true; } else if (msg.startsWith(RANGE)) { swapRange = true; } else if (msg.startsWith(MELEE)) { swapMelee = true; } }
Example #6
Source File: ChatNotificationsPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testHighlightOwnNameNbsp() { Player player = mock(Player.class); when(player.getName()).thenReturn("Logic Knot"); when(client.getLocalPlayer()).thenReturn(player); when(config.highlightOwnName()).thenReturn(true); MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn("<col=005f00>Logic\u00a0Knot received a drop: Adamant longsword</col>"); ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0); chatNotificationsPlugin.onChatMessage(chatMessage); // set value uses our player name, which has nbsp replaced verify(messageNode).setValue("<col=005f00><colHIGHLIGHT><u>Logic Knot</u><colNORMAL> received a drop: Adamant longsword</col>"); }
Example #7
Source File: DriftNetPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (!inDriftNetArea) { return; } if (event.getType() == ChatMessageType.SPAM && event.getMessage().equals(CHAT_PRODDING_FISH)) { Actor target = client.getLocalPlayer().getInteracting(); if (target instanceof NPC && ((NPC) target).getId() == NpcID.FISH_SHOAL) { tagFish(target); } else { // If the fish is on an adjacent tile, the interaction change happens after // the chat message is sent, so we arm it armInteraction = true; } } }
Example #8
Source File: WoodcuttingPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe void onChatMessage(ChatMessage event) { if (event.getType() == ChatMessageType.SPAM || event.getType() == ChatMessageType.GAMEMESSAGE) { if (WOOD_CUT_PATTERN.matcher(event.getMessage()).matches()) { if (session == null) { session = new WoodcuttingSession(); gpEarned = 0; } session.setLastChopping(); typeOfLogCut(event.getMessage()); gpEarned += itemManager.getItemPrice(treeTypeID); } if (event.getMessage().contains("A bird's nest falls out of the tree") && config.showNestNotification()) { notifier.notify("A bird nest has spawned!"); } } }
Example #9
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testTaskLookupInvalid() throws IOException { net.runelite.http.api.chat.Task task = new net.runelite.http.api.chat.Task(); task.setTask("task<"); task.setLocation("loc"); task.setAmount(42); task.setInitialAmount(42); when(slayerConfig.taskCommand()).thenReturn(true); when(chatClient.getTask(anyString())).thenReturn(task); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setName("Adam"); chatMessage.setMessageNode(mock(MessageNode.class)); slayerPlugin.taskLookup(chatMessage, "!task"); verify(chatMessageManager, never()).update(any(MessageNode.class)); }
Example #10
Source File: ChatNotificationsPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void onChatMessage() { when(config.highlightWordsString()).thenReturn("Deathbeam, Deathbeam OSRS , test"); MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn("Deathbeam, Deathbeam OSRS"); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setMessageNode(messageNode); chatNotificationsPlugin.startUp(); // load highlight config chatNotificationsPlugin.onChatMessage(chatMessage); verify(messageNode).setValue("<colHIGHLIGHT>Deathbeam<colNORMAL>, <colHIGHLIGHT>Deathbeam<colNORMAL> OSRS"); }
Example #11
Source File: ChatNotificationsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void sendNotification(ChatMessage message) { String name = Text.removeTags(message.getName()); String sender = message.getSender(); StringBuilder stringBuilder = new StringBuilder(); if (!Strings.isNullOrEmpty(sender)) { stringBuilder.append('[').append(sender).append("] "); } if (!Strings.isNullOrEmpty(name)) { stringBuilder.append(name).append(": "); } stringBuilder.append(Text.removeTags(message.getMessage())); String notification = stringBuilder.toString(); notifier.notify(notification); }
Example #12
Source File: FishingPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SPAM) { return; } if (event.getMessage().contains("You catch a") || event.getMessage().contains("You catch some") || event.getMessage().equals("Your cormorant returns with its catch.")) { session.setLastFishCaught(Instant.now()); spotOverlay.setHidden(false); fishingSpotMinimapOverlay.setHidden(false); } }
Example #13
Source File: SlayerPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testTaskLookupInvalid() { net.runelite.http.api.chat.Task task = new net.runelite.http.api.chat.Task(); task.setTask("task<"); task.setLocation("loc"); task.setAmount(42); task.setInitialAmount(42); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setName("Adam"); chatMessage.setMessageNode(mock(MessageNode.class)); slayerPlugin.taskLookup(chatMessage, "!task"); verify(chatMessageManager, never()).update(any(MessageNode.class)); }
Example #14
Source File: ChatNotificationsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testEmoji() { when(config.highlightWordsString()).thenReturn("test"); String message = "emoji test <img=29>"; MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn(message); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setMessageNode(messageNode); chatNotificationsPlugin.startUp(); // load highlight config chatNotificationsPlugin.onChatMessage(chatMessage); verify(messageNode).setValue("emoji <colHIGHLIGHT>test<colNORMAL> <img=29>"); }
Example #15
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testCombatBraceletUpdate() { final Player player = mock(Player.class); when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0)); when(client.getLocalPlayer()).thenReturn(player); slayerPlugin.setTaskName("Suqahs"); slayerPlugin.setAmount(231); ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", TASK_UPDATE_COMBAT_BRACELET, null, 0); slayerPlugin.onChatMessage(chatMessage); assertEquals("Suqahs", slayerPlugin.getTaskName()); slayerPlugin.killedOne(); assertEquals(30, slayerPlugin.getAmount()); }
Example #16
Source File: ChatNotificationsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testPreceedingColor() { when(config.highlightWordsString()).thenReturn("you. It"); String message = "Your dodgy <col=00ff00>necklace protects you. It has 1 charge left.</col>"; MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn(message); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setMessageNode(messageNode); chatNotificationsPlugin.startUp(); // load highlight config chatNotificationsPlugin.onChatMessage(chatMessage); verify(messageNode).setValue("Your dodgy <col=00ff00>necklace protects <colHIGHLIGHT>you. It<col=00ff00> has 1 charge left.</col>"); }
Example #17
Source File: FriendsChatPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void insertRankIcon(final ChatMessage message) { final FriendsChatRank rank = friendChatManager.getRank(message.getName()); if (rank != null && rank != FriendsChatRank.UNRANKED) { int iconNumber = friendChatManager.getIconNumber(rank); final String img = "<img=" + iconNumber + ">"; if (message.getType() == ChatMessageType.FRIENDSCHAT) { message.getMessageNode() .setSender(message.getMessageNode().getSender() + " " + img); } else { message.getMessageNode() .setName(img + message.getMessageNode().getName()); } client.refreshChat(); } }
Example #18
Source File: DriftNetPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (!inDriftNetArea) { return; } if (event.getType() == ChatMessageType.SPAM && event.getMessage().equals(CHAT_PRODDING_FISH)) { Actor target = client.getLocalPlayer().getInteracting(); if (target instanceof NPC && ((NPC) target).getId() == NpcID.FISH_SHOAL) { tagFish(target); } else { // If the fish is on an adjacent tile, the interaction change happens after // the chat message is sent, so we arm it armInteraction = true; } } }
Example #19
Source File: EmojiPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testGtLt() { when(client.getGameState()).thenReturn(GameState.LOGGED_IN); when(client.getModIcons()).thenReturn(new IndexedSprite[0]); when(client.createIndexedSprite()).thenReturn(mock(IndexedSprite.class)); // Trip emoji loading GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGGED_IN); emojiPlugin.onGameStateChanged(gameStateChanged); MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn("<gt>:D<lt>"); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setMessageNode(messageNode); emojiPlugin.onChatMessage(chatMessage); verify(messageNode).setRuneLiteFormatMessage("<img=10>"); }
Example #20
Source File: ChatNotificationsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testHighlightOwnNameNbsp() { Player player = mock(Player.class); when(player.getName()).thenReturn("Logic Knot"); when(client.getLocalPlayer()).thenReturn(player); when(config.highlightOwnName()).thenReturn(true); MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn("<col=005f00>Logic\u00a0Knot received a drop: Adamant longsword</col>"); ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0); chatNotificationsPlugin.onChatMessage(chatMessage); // set value uses our player name, which has nbsp replaced verify(messageNode).setValue("<col=005f00><colHIGHLIGHT><u>Logic Knot</u><colNORMAL> received a drop: Adamant longsword</col>"); }
Example #21
Source File: ChatNotificationsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void sendNotification(ChatMessage message) { String name = Text.removeTags(message.getName()); String sender = message.getSender(); StringBuilder stringBuilder = new StringBuilder(); if (!Strings.isNullOrEmpty(sender)) { stringBuilder.append('[').append(sender).append("] "); } if (!Strings.isNullOrEmpty(name)) { stringBuilder.append(name).append(": "); } stringBuilder.append(Text.removeTags(message.getMessage())); String notification = stringBuilder.toString(); notifier.notify(notification); }
Example #22
Source File: BarbarianAssaultPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() == ChatMessageType.GAMEMESSAGE && event.getMessage().startsWith("---- Wave:")) { String[] message = event.getMessage().split(" "); currentWave = message[BA_WAVE_NUM_INDEX]; if (currentWave.equals(START_WAVE)) { gameTime = new GameTimer(); } else if (gameTime != null) { gameTime.setWaveStartTime(); } } }
Example #23
Source File: ChatCommandsPluginTest.java From plugins with GNU General Public License v3.0 | 5 votes |
@Test public void testCorruptedGauntlet() { ChatMessage corruptedGauntletMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your Corrupted Gauntlet completion count is: <col=ff0000>4729</col>.", null, 0); chatCommandsPlugin.onChatMessage(corruptedGauntletMessage); verify(configManager).setConfiguration("killcount.adam", "corrupted gauntlet", 4729); }
Example #24
Source File: WoodcuttingPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testOakLogs() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You get some oak logs.", "", 0); woodcuttingPlugin.onChatMessage(chatMessage); assertNotNull(woodcuttingPlugin.getSession()); }
Example #25
Source File: PestControlPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onChatMessage(ChatMessage chatMessage) { if (overlay.getGame() != null && chatMessage.getType() == ChatMessageType.GAMEMESSAGE) { Matcher matcher = SHIELD_DROP.matcher(chatMessage.getMessage()); if (matcher.lookingAt()) { overlay.getGame().fall(matcher.group(1)); } } }
Example #26
Source File: ScreenshotPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testUntradeableDrop() { ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", UNTRADEABLE_DROP, null, 0); screenshotPlugin.onChatMessage(chatMessageEvent); verify(drawManager).requestNextFrameListener(any(Consumer.class)); }
Example #27
Source File: ChatTranslationPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onChatMessage(ChatMessage chatMessage) { if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN) { return; } switch (chatMessage.getType()) { case PUBLICCHAT: case MODCHAT: case FRIENDSCHAT: break; default: return; } if (!playerNames.contains(Text.toJagexName(Text.removeTags(chatMessage.getName().toLowerCase())))) { return; } final String message = chatMessage.getMessage(); try { final String translation = translator.translateIncoming(message); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(translation); chatMessageManager.update(messageNode); } catch (IOException ignored) { } client.refreshChat(); }
Example #28
Source File: ChatCommandsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testCorruptedGauntlet() { ChatMessage corruptedGauntletMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your Corrupted Gauntlet completion count is: <col=ff0000>4729</col>.", null, 0); chatCommandsPlugin.onChatMessage(corruptedGauntletMessage); verify(configManager).setConfiguration("killcount.adam", "corrupted gauntlet", 4729); }
Example #29
Source File: CookingPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testOnChatMessage() { for (String message : COOKING_MESSAGES) { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", message, "", 0); cookingPlugin.onChatMessage(chatMessage); } CookingSession cookingSession = cookingPlugin.getSession(); assertNotNull(cookingSession); assertEquals(COOKING_MESSAGES.length, cookingSession.getCookAmount()); }
Example #30
Source File: ChatCommandsPluginTest.java From plugins with GNU General Public License v3.0 | 5 votes |
@Test public void testTheatreOfBloodNoPB() { when(configManager.getConfiguration("personalbest.adam", "theatre of blood", int.class)).thenReturn(37 * 60 + 4); // 37:04 ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Wave 'The Final Challenge' complete! Duration: <col=ff0000>5:04</col><br>Theatre of Blood wave completion time: <col=ff0000>38:17</col><br></col>Personal best: 37:10", null, 0); chatCommandsPlugin.onChatMessage(chatMessage); ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: <col=ff0000>73</col>.", null, 0); chatCommandsPlugin.onChatMessage(chatMessageEvent); verify(configManager).setConfiguration("killcount.adam", "theatre of blood", 73); verify(configManager, never()).setConfiguration(eq("personalbest.adam"), eq("theatre of blood"), anyInt()); }