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

The following examples show how to use net.runelite.api.events.ChatMessage#setMessageNode() . 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 vote down vote up
@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: 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 3
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 4
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 5
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 6
Source File: SlayerPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 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: SlayerPluginTest.java    From plugins with GNU General Public License v3.0 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 11
Source File: EmojiPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 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 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 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 16
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 17
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 18
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 19
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 20
Source File: ChatCommandsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 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");
}