net.runelite.api.ChatMessageType Java Examples
The following examples show how to use
net.runelite.api.ChatMessageType.
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: ChatCommandsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
/** * Gets correct lookup data for message * * @param chatMessage chat message * @return hiscore lookup data */ private HiscoreLookup getCorrectLookupFor(final ChatMessage chatMessage) { Player localPlayer = client.getLocalPlayer(); final String player = Text.sanitize(chatMessage.getName()); // If we are sending the message then just use the local hiscore endpoint for the world if (chatMessage.getType().equals(ChatMessageType.PRIVATECHATOUT) || player.equals(localPlayer.getName())) { return new HiscoreLookup(localPlayer.getName(), hiscoreEndpoint); } // Public chat on a leagues world is always league hiscores, regardless of icon if (chatMessage.getType() == ChatMessageType.PUBLICCHAT || chatMessage.getType() == ChatMessageType.MODCHAT) { if (client.getWorldType().contains(WorldType.LEAGUE)) { return new HiscoreLookup(player, HiscoreEndpoint.LEAGUE); } } // Get ironman status from their icon in chat HiscoreEndpoint endpoint = getHiscoreEndpointByName(chatMessage.getName()); return new HiscoreLookup(player, endpoint); }
Example #2
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 #3
Source File: SlayerPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testTaskLookup() throws IOException { net.runelite.http.api.chat.Task task = new net.runelite.http.api.chat.Task(); task.setTask("Abyssal demons"); task.setLocation("Abyss"); task.setAmount(42); task.setInitialAmount(42); when(slayerConfig.taskCommand()).thenReturn(true); when(chatClient.getTask(anyString())).thenReturn(task); ChatMessage setMessage = new ChatMessage(); setMessage.setType(ChatMessageType.PUBLICCHAT); setMessage.setName("Adam"); setMessage.setMessageNode(mock(MessageNode.class)); slayerPlugin.taskLookup(setMessage, "!task"); verify(chatMessageManager).update(any(MessageNode.class)); }
Example #4
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 #5
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 #6
Source File: ChatFilterPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private ScriptCallbackEvent createCallbackEvent(final String sender, final String chatMessage, final ChatMessageType messageType) { ScriptCallbackEvent event = new ScriptCallbackEvent(); event.setScript(null); event.setEventName("chatFilterCheck"); int[] simulatedIntStack = new int[]{1, messageType.getType(), 1}; // is msg allowed to show, ChatMessageType.PUBLICCHAT, message id String[] simulatedStringStack = new String[]{chatMessage}; IterableHashTable<MessageNode> messageTable = mock(IterableHashTable.class); MessageNode mockedMsgNode = mockMessageNode(sender); when(client.getIntStack()).thenReturn(simulatedIntStack); when(client.getIntStackSize()).thenReturn(simulatedIntStack.length); when(client.getStringStack()).thenReturn(simulatedStringStack); when(client.getStringStackSize()).thenReturn(simulatedStringStack.length); when(client.getMessages()).thenReturn(messageTable); when(messageTable.get(1)).thenReturn(mockedMsgNode); return event; }
Example #7
Source File: BronzeManPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void handleItemAction(String itemName) { if (itemName.equalsIgnoreCase("cat ears")) { sendMessage("Now we just need elf ears.."); } final ChatMessageBuilder message = new ChatMessageBuilder() .append(ChatColorType.NORMAL) .append("It's a " + itemName); chatMessageManager.queue(QueuedMessage.builder() .type(ChatMessageType.ITEM_EXAMINE) .runeLiteFormattedMessage(message.build()) .build()); }
Example #8
Source File: ChatNotificationsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testLtGt() { when(config.highlightWordsString()).thenReturn("<test>"); String message = "test <lt>test<gt> test"; 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("test <colHIGHLIGHT><lt>test<gt><colNORMAL> test"); }
Example #9
Source File: ChatNotificationsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testNonMatchedColors() { when(config.highlightWordsString()).thenReturn("test"); String message = "<col=ff0000>color</col> 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("<col=ff0000>color</col> <colHIGHLIGHT>test<colNORMAL> <img=29>"); }
Example #10
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 #11
Source File: ChatFilterPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
private ScriptCallbackEvent createCallbackEvent(final String sender, final String chatMessage, final ChatMessageType messageType) { ScriptCallbackEvent event = new ScriptCallbackEvent(); event.setScript(null); event.setEventName("chatFilterCheck"); int[] simulatedIntStack = new int[]{1, messageType.getType(), 1}; // is msg allowed to show, ChatMessageType.PUBLICCHAT, message id String[] simulatedStringStack = new String[]{chatMessage}; IterableHashTable messageTable = mock(IterableHashTable.class); MessageNode mockedMsgNode = mockMessageNode(sender); when(client.getIntStack()).thenReturn(simulatedIntStack); when(client.getIntStackSize()).thenReturn(simulatedIntStack.length); when(client.getStringStack()).thenReturn(simulatedStringStack); when(client.getStringStackSize()).thenReturn(simulatedStringStack.length); when(client.getMessages()).thenReturn(messageTable); when(messageTable.get(1)).thenReturn(mockedMsgNode); return event; }
Example #12
Source File: ChatNotificationsPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testColor() { when(config.highlightWordsString()).thenReturn("you. It"); String message = "Your dodgy necklace protects you. <col=ff0000>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 necklace protects <colHIGHLIGHT>you. It<col=ff0000> has 1 charge left.</col>"); }
Example #13
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 #14
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 #15
Source File: ChatNotificationsPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testHighlightOwnName() { 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 Knot received a drop: Adamant longsword</col>"); ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0); chatNotificationsPlugin.onChatMessage(chatMessage); verify(messageNode).setValue("<col=005f00><colHIGHLIGHT><u>Logic Knot</u><colNORMAL> received a drop: Adamant longsword</col>"); }
Example #16
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 #17
Source File: PartyPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onOverlayMenuClicked(OverlayMenuClicked event) { if (event.getEntry().getMenuAction() == MenuAction.RUNELITE_OVERLAY && event.getEntry().getTarget().equals("Party") && event.getEntry().getOption().equals("Leave")) { party.changeParty(null); if (!config.messages()) { return; } final String leaveMessage = new ChatMessageBuilder() .append(ChatColorType.HIGHLIGHT) .append("You have left the party.") .build(); chatMessageManager.queue(QueuedMessage.builder() .type(ChatMessageType.FRIENDSCHATNOTIFICATION) .runeLiteFormattedMessage(leaveMessage) .build()); } }
Example #18
Source File: RunecraftPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.GAMEMESSAGE) { return; } if (config.degradingNotification()) { if (event.getMessage().contains(POUCH_DECAYED_MESSAGE)) { notifier.notify(POUCH_DECAYED_NOTIFICATION_MESSAGE); } } }
Example #19
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 #20
Source File: PartyPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onUserPart(final UserPart event) { final PartyData removed = partyDataMap.remove(event.getMemberId()); if (removed != null) { if (config.messages()) { final String joinMessage = new ChatMessageBuilder() .append(ChatColorType.HIGHLIGHT) .append(removed.getName()) .append(" has left the party!") .build(); chatMessageManager.queue(QueuedMessage.builder() .type(ChatMessageType.FRIENDSCHATNOTIFICATION) .runeLiteFormattedMessage(joinMessage) .build()); } worldMapManager.remove(removed.getWorldMapPoint()); } }
Example #21
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 #22
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testTaskLookup() throws IOException { net.runelite.http.api.chat.Task task = new net.runelite.http.api.chat.Task(); task.setTask("Abyssal demons"); task.setLocation("Abyss"); task.setAmount(42); task.setInitialAmount(42); when(slayerConfig.taskCommand()).thenReturn(true); when(chatClient.getTask(anyString())).thenReturn(task); ChatMessage setMessage = new ChatMessage(); setMessage.setType(ChatMessageType.PUBLICCHAT); setMessage.setName("Adam"); setMessage.setMessageNode(mock(MessageNode.class)); slayerPlugin.taskLookup(setMessage, "!task"); verify(chatMessageManager).update(any(MessageNode.class)); }
Example #23
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 #24
Source File: ChatCommandsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testPlayerSkillLookup() throws IOException { Player player = mock(Player.class); when(player.getName()).thenReturn(PLAYER_NAME); when(client.getLocalPlayer()).thenReturn(player); when(chatCommandsConfig.lvl()).thenReturn(true); ArgumentCaptor<BiConsumer<ChatMessage, String>> captor = ArgumentCaptor.forClass(BiConsumer.class); verify(chatCommandManager).registerCommandAsync(eq("!lvl"), captor.capture()); BiConsumer<ChatMessage, String> value = captor.getValue(); SingleHiscoreSkillResult skillResult = new SingleHiscoreSkillResult(); skillResult.setPlayer(PLAYER_NAME); skillResult.setSkill(new Skill(10, 1000, -1)); when(hiscoreClient.lookup(PLAYER_NAME, HiscoreSkill.ZULRAH, null)).thenReturn(skillResult); MessageNode messageNode = mock(MessageNode.class); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setName(PLAYER_NAME); chatMessage.setMessageNode(messageNode); value.accept(chatMessage, "!lvl zulrah"); verify(messageNode).setRuneLiteFormatMessage("<colNORMAL>Level <colHIGHLIGHT>Zulrah: 1000<colNORMAL> Rank: <colHIGHLIGHT>10"); }
Example #25
Source File: WorldHopperPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGameTick(GameTick event) { if (quickHopTargetWorld == null) { return; } if (client.getWidget(WidgetInfo.WORLD_SWITCHER_LIST) == null) { client.openWorldHopper(); if (++displaySwitcherAttempts >= DISPLAY_SWITCHER_MAX_ATTEMPTS) { String chatMessage = new ChatMessageBuilder() .append(ChatColorType.NORMAL) .append("Failed to quick-hop after ") .append(ChatColorType.HIGHLIGHT) .append(Integer.toString(displaySwitcherAttempts)) .append(ChatColorType.NORMAL) .append(" attempts.") .build(); chatMessageManager .queue(QueuedMessage.builder() .type(ChatMessageType.CONSOLE) .runeLiteFormattedMessage(chatMessage) .build()); resetQuickHopper(); } } else { client.hopToWorld(quickHopTargetWorld); resetQuickHopper(); } }
Example #26
Source File: ChatFilterPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testEventCensorWordsByName() { when(chatFilterConfig.filteredNames()).thenReturn("Gamble [0-9]*"); when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_WORDS); chatFilterPlugin.updateFilteredPatterns(); ScriptCallbackEvent event = createCallbackEvent("Gamble 1234", "filterme", ChatMessageType.PUBLICCHAT); chatFilterPlugin.onScriptCallbackEvent(event); assertEquals("********", client.getStringStack()[client.getStringStackSize() - 1]); }
Example #27
Source File: WoodcuttingPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testArcticLogs() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You get an arctic log.", "", 0); woodcuttingPlugin.onChatMessage(chatMessage); assertNotNull(woodcuttingPlugin.getSession()); }
Example #28
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 #29
Source File: HiscorePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onChatMessage(ChatMessage event) { if (!config.bountylookup() || !event.getType().equals(ChatMessageType.GAMEMESSAGE)) { return; } String message = event.getMessage(); Matcher m = BOUNTY_PATTERN.matcher(message); if (m.matches()) { lookupPlayer(m.group(1)); } }
Example #30
Source File: RemindersPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void personalReminder2() { if (!config.personalReminders() && !config.personalReminder2()) { log.error("personalReminder2 - Unexpected value: " + config.personalReminderText2() + hours); } chatMessageManager.queue(QueuedMessage.builder().type(ChatMessageType.CONSOLE).runeLiteFormattedMessage( new ChatMessageBuilder() .append(ChatColorType.HIGHLIGHT) .append(config.personalReminderText2()) .build()) .build()); }