EmojiPlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage chatMessage) { if (client.getGameState() != GameState.LOGGED_IN || modIconsStart == -1) { return; } switch (chatMessage.getType()) { case PUBLICCHAT: case MODCHAT: case FRIENDSCHAT: case PRIVATECHAT: case PRIVATECHATOUT: case MODPRIVATECHAT: break; default: return; } final MessageNode messageNode = chatMessage.getMessageNode(); final String message = messageNode.getValue(); final String updatedMessage = updateMessage(message); if (updatedMessage == null) { return; } messageNode.setRuneLiteFormatMessage(updatedMessage); chatMessageManager.update(messageNode); client.refreshChat(); }  @Subscribe void onGameStateChanged(GameStateChanged gameStateChanged); @Subscribe void onChatMessage(ChatMessage chatMessage); @Subscribe void onOverheadTextChanged(final OverheadTextChanged event);  }
@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)); GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGGED_IN); emojiPlugin.onGameStateChanged(gameStateChanged); MessageNode messageNode = mock(MessageNode.class); 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>"); }