Java Code Examples for net.runelite.api.events.ChatMessage#setType()

The following examples show how to use net.runelite.api.events.ChatMessage#setType() . 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: SlayerPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 2
Source File: ChatNotificationsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testFullStop()
{
	when(config.highlightWordsString()).thenReturn("test");

	String message = "foo test. bar";
	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("foo <colHIGHLIGHT>test<colNORMAL>. bar");
}
 
Example 3
Source File: ChatNotificationsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 4
Source File: ChatNotificationsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 5
Source File: ChatNotificationsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 6
Source File: ChatNotificationsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 7
Source File: SlayerPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 8
Source File: ChatMessageManagerTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void onChatMessage()
{
	when(chatColorConfig.opaquePublicChat()).thenReturn(Color.decode("#b20000"));

	chatMessageManager.loadColors();

	ChatMessage chatMessage = new ChatMessage();
	chatMessage.setType(ChatMessageType.PUBLICCHAT);

	MessageNode messageNode = mock(MessageNode.class);
	chatMessage.setMessageNode(messageNode);

	when(messageNode.getValue()).thenReturn("Your dodgy necklace protects you. It has <col=ff0000>1</col> charge left.");
	chatMessageManager.onChatMessage(chatMessage);

	verify(messageNode).setValue(eq("<col=b20000>Your dodgy necklace protects you. It has <col=ff0000>1<col=b20000> charge left.</col>"));
}
 
Example 9
Source File: EmojiPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 10
Source File: ChatNotificationsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 11
Source File: ChatNotificationsPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 12
Source File: ChatNotificationsPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 13
Source File: ChatNotificationsPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 14
Source File: ChatNotificationsPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 15
Source File: ChatNotificationsPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 16
Source File: ChatNotificationsPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 17
Source File: ChatNotificationsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 18
Source File: ClueScrollPluginTest.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testLocationHintArrowCleared()
{
	final Widget clueWidget = mock(Widget.class);
	when(clueWidget.getText()).thenReturn("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Reldo may have a clue.");
	final ChatMessage hotColdMessage = new ChatMessage();
	hotColdMessage.setType(ChatMessageType.GAMEMESSAGE);
	final Player localPlayer = mock(Player.class);

	when(client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT)).thenReturn(clueWidget);
	when(client.getLocalPlayer()).thenReturn(localPlayer);
	when(client.getPlane()).thenReturn(0);
	when(client.getCachedNPCs()).thenReturn(new NPC[]{});

	// The hint arrow should be reset each game tick from when the clue is read onward
	// This is to verify the arrow is cleared the correct number of times during the clue updating process.
	int clueSetupHintArrowClears = 0;

	// Perform the first hot-cold check in Lumbridge near sheep pen (get 2 possible points: LUMBRIDGE_COW_FIELD and DRAYNOR_WHEAT_FIELD)
	when(localPlayer.getWorldLocation()).thenReturn(new WorldPoint(3208, 3254, 0));
	hotColdMessage.setMessage("The device is hot.");
	plugin.onChatMessage(hotColdMessage);

	// Move to SW of DRAYNOR_WHEAT_FIELD (hint arrow should be visible here)
	when(localPlayer.getWorldLocation()).thenReturn(new WorldPoint(3105, 3265, 0));
	when(client.getBaseX()).thenReturn(3056);
	when(client.getBaseY()).thenReturn(3216);
	plugin.onGameTick(GameTick.INSTANCE);

	// Test in that location (get 1 possible location: LUMBRIDGE_COW_FIELD)
	hotColdMessage.setMessage("The device is hot, and warmer than last time.");
	plugin.onChatMessage(hotColdMessage);
	plugin.onGameTick(GameTick.INSTANCE);
}
 
Example 19
Source File: ChatCommandsPluginTest.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@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 20
Source File: ClueScrollPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Test
public void testLocationHintArrowCleared()
{
	final Widget clueWidget = mock(Widget.class);
	when(clueWidget.getText()).thenReturn("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Reldo may have a clue.");
	final ChatMessage hotColdMessage = new ChatMessage();
	hotColdMessage.setType(ChatMessageType.GAMEMESSAGE);
	final Player localPlayer = mock(Player.class);

	when(client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT)).thenReturn(clueWidget);
	when(client.getLocalPlayer()).thenReturn(localPlayer);
	when(client.getPlane()).thenReturn(0);
	when(client.getCachedNPCs()).thenReturn(new NPC[] {});
	when(config.displayHintArrows()).thenReturn(true);

	// The hint arrow should be reset each game tick from when the clue is read onward
	// This is to verify the arrow is cleared the correct number of times during the clue updating process.
	int clueSetupHintArrowClears = 0;

	// Initialize a beginner hot-cold clue (which will have an end point of LUMBRIDGE_COW_FIELD)
	plugin.onGameTick(new GameTick());
	verify(client, times(++clueSetupHintArrowClears)).clearHintArrow();

	// Perform the first hot-cold check in Lumbridge near sheep pen (get 2 possible points: LUMBRIDGE_COW_FIELD and DRAYNOR_WHEAT_FIELD)
	when(localPlayer.getWorldLocation()).thenReturn(new WorldPoint(3208, 3254, 0));
	hotColdMessage.setMessage("The device is hot.");
	plugin.onChatMessage(hotColdMessage);

	// Move to SW of DRAYNOR_WHEAT_FIELD (hint arrow should be visible here)
	when(localPlayer.getWorldLocation()).thenReturn(new WorldPoint(3105, 3265, 0));
	when(client.getBaseX()).thenReturn(3056);
	when(client.getBaseY()).thenReturn(3216);
	plugin.onGameTick(new GameTick());
	verify(client, times(++clueSetupHintArrowClears)).clearHintArrow();
	verify(client).setHintArrow(HotColdLocation.DRAYNOR_WHEAT_FIELD.getWorldPoint());

	// Test in that location (get 1 possible location: LUMBRIDGE_COW_FIELD)
	hotColdMessage.setMessage("The device is hot, and warmer than last time.");
	plugin.onChatMessage(hotColdMessage);
	plugin.onGameTick(new GameTick());

	// Hint arrow should be cleared and not re-set now as the only remaining location is outside of the current
	// scene
	verify(client, times(++clueSetupHintArrowClears)).clearHintArrow();
	verify(client, times(1)).setHintArrow(any(WorldPoint.class));
}