chat commands: unregister bh and lms commands
This commit is contained in:
@@ -202,7 +202,10 @@ public class ChatCommandsPlugin extends Plugin
|
||||
chatCommandManager.unregisterCommand(CMB_COMMAND_STRING);
|
||||
chatCommandManager.unregisterCommand(PRICE_COMMAND_STRING);
|
||||
chatCommandManager.unregisterCommand(LEVEL_COMMAND_STRING);
|
||||
chatCommandManager.unregisterCommand(BOUNTY_HUNTER_HUNTER_COMMAND);
|
||||
chatCommandManager.unregisterCommand(BOUNTY_HUNTER_ROGUE_COMMAND);
|
||||
chatCommandManager.unregisterCommand(CLUES_COMMAND_STRING);
|
||||
chatCommandManager.unregisterCommand(LAST_MAN_STANDING_COMMAND);
|
||||
chatCommandManager.unregisterCommand(KILLCOUNT_COMMAND_STRING);
|
||||
chatCommandManager.unregisterCommand(QP_COMMAND_STRING);
|
||||
chatCommandManager.unregisterCommand(PB_COMMAND);
|
||||
@@ -1049,7 +1052,8 @@ public class ChatCommandsPlugin extends Plugin
|
||||
* @param chatMessage The chat message containing the command.
|
||||
* @param message The chat message
|
||||
*/
|
||||
private void playerSkillLookup(ChatMessage chatMessage, String message)
|
||||
@VisibleForTesting
|
||||
void playerSkillLookup(ChatMessage chatMessage, String message)
|
||||
{
|
||||
if (!config.lvl())
|
||||
{
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.chatcommands;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import static net.runelite.api.ChatMessageType.FRIENDSCHATNOTIFICATION;
|
||||
@@ -54,7 +54,7 @@ import net.runelite.http.api.hiscore.HiscoreClient;
|
||||
import net.runelite.http.api.hiscore.HiscoreSkill;
|
||||
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
|
||||
import net.runelite.http.api.hiscore.Skill;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -64,6 +64,7 @@ import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -120,15 +121,28 @@ public class ChatCommandsPluginTest
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
|
||||
when(client.getUsername()).thenReturn(PLAYER_NAME);
|
||||
Player player = mock(Player.class);
|
||||
when(player.getName()).thenReturn(PLAYER_NAME);
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
chatCommandsPlugin.startUp();
|
||||
when(client.getUsername()).thenReturn(PLAYER_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after()
|
||||
@Test
|
||||
public void testStartupShutdown()
|
||||
{
|
||||
chatCommandsPlugin.startUp();
|
||||
chatCommandsPlugin.shutDown();
|
||||
|
||||
ArgumentCaptor<String> registerCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(chatCommandManager, atLeastOnce()).registerCommand(registerCaptor.capture(), any());
|
||||
verify(chatCommandManager, atLeastOnce()).registerCommandAsync(registerCaptor.capture(), any());
|
||||
verify(chatCommandManager, atLeastOnce()).registerCommandAsync(registerCaptor.capture(), any(), any());
|
||||
|
||||
ArgumentCaptor<String> unregisterCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(chatCommandManager, atLeastOnce()).unregisterCommand(unregisterCaptor.capture());
|
||||
|
||||
assertEquals(Sets.newHashSet(registerCaptor.getAllValues()), Sets.newHashSet(unregisterCaptor.getAllValues()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -448,10 +462,6 @@ public class ChatCommandsPluginTest
|
||||
@Test
|
||||
public void testAdventureLogCountersPage()
|
||||
{
|
||||
Player player = mock(Player.class);
|
||||
when(player.getName()).thenReturn(PLAYER_NAME);
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
Widget advLogWidget = mock(Widget.class);
|
||||
Widget advLogExploitsTextWidget = mock(Widget.class);
|
||||
when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget);
|
||||
@@ -505,10 +515,6 @@ public class ChatCommandsPluginTest
|
||||
@Test
|
||||
public void testAdventurerLogCountersPage2()
|
||||
{
|
||||
Player player = mock(Player.class);
|
||||
when(player.getName()).thenReturn(PLAYER_NAME);
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
Widget advLogWidget = mock(Widget.class);
|
||||
Widget advLogExploitsTextWidget = mock(Widget.class);
|
||||
when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget);
|
||||
@@ -559,10 +565,6 @@ public class ChatCommandsPluginTest
|
||||
@Test
|
||||
public void testNotYourAdventureLogCountersPage()
|
||||
{
|
||||
Player player = mock(Player.class);
|
||||
when(player.getName()).thenReturn(PLAYER_NAME);
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
Widget advLogWidget = mock(Widget.class);
|
||||
Widget advLogExploitsTextWidget = mock(Widget.class);
|
||||
when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget);
|
||||
@@ -585,14 +587,7 @@ public class ChatCommandsPluginTest
|
||||
@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);
|
||||
@@ -606,7 +601,7 @@ public class ChatCommandsPluginTest
|
||||
chatMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||
chatMessage.setName(PLAYER_NAME);
|
||||
chatMessage.setMessageNode(messageNode);
|
||||
value.accept(chatMessage, "!lvl zulrah");
|
||||
chatCommandsPlugin.playerSkillLookup(chatMessage, "!lvl zulrah");
|
||||
|
||||
verify(messageNode).setRuneLiteFormatMessage("<colNORMAL>Level <colHIGHLIGHT>Zulrah: 1000<colNORMAL> Rank: <colHIGHLIGHT>10");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user