Merge branch 'master' into runelite-master-1

This commit is contained in:
Tyler Bochard
2019-07-05 01:03:38 -04:00
committed by GitHub
995 changed files with 37347 additions and 32076 deletions

View File

@@ -61,7 +61,7 @@ public class BankCalculationTest
private BankConfig bankConfig;
@Inject
private BankCalculation bankCalculation;
private BankPlugin bankplugin;
@Before
public void before()
@@ -107,6 +107,7 @@ public class BankCalculationTest
when(itemManager.getItemDefinition(ItemID.ABYSSAL_WHIP))
.thenReturn(whipComp);
BankCalculation bankCalculation = new BankCalculation(itemManager, bankplugin, client);
bankCalculation.calculate();
long value = bankCalculation.getHaPrice();

View File

@@ -71,7 +71,7 @@ public class CerberusPluginTest
mockNpc(new LocalPoint(2, 5)),
mockNpc(new LocalPoint(1, 5))
));
cerberusPlugin.onGameTick(new GameTick());
cerberusPlugin.onGameTick(GameTick.INSTANCE);
// Expected sort is by lowest y first, then by lowest x
assertEquals(ghosts.get(0).getLocalLocation(), new LocalPoint(0, 0));

View File

@@ -65,16 +65,17 @@ public class ChatFilterPluginTest
{
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_WORDS);
when(chatFilterConfig.filteredWords()).thenReturn("");
when(chatFilterConfig.filteredRegex()).thenReturn("");
chatFilterPlugin.setFilterType(ChatFilterType.CENSOR_WORDS);
chatFilterPlugin.setFilteredWords("");
chatFilterPlugin.setFilteredRegex("");
when(client.getLocalPlayer()).thenReturn(localPlayer);
}
@Test
public void testCensorWords()
{
when(chatFilterConfig.filteredWords()).thenReturn("hat");
chatFilterPlugin.setFilteredWords("hat");
chatFilterPlugin.updateFilteredPatterns();
assertEquals("w***s up", chatFilterPlugin.censorMessage("whats up"));
@@ -83,8 +84,8 @@ public class ChatFilterPluginTest
@Test
public void testCensorRegex()
{
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE);
when(chatFilterConfig.filteredRegex()).thenReturn("5[0-9]x2\n(");
chatFilterPlugin.setFilterType(ChatFilterType.REMOVE_MESSAGE);
chatFilterPlugin.setFilteredRegex("5[0-9]x2\n(");
chatFilterPlugin.updateFilteredPatterns();
assertNull(chatFilterPlugin.censorMessage("55X2 Dicing | Trusted Ranks | Huge Pay Outs!"));
@@ -93,7 +94,7 @@ public class ChatFilterPluginTest
@Test
public void testBrokenRegex()
{
when(chatFilterConfig.filteredRegex()).thenReturn("Test\n)\n73");
chatFilterPlugin.setFilteredRegex("Test\n)\n73");
chatFilterPlugin.updateFilteredPatterns();
assertEquals("** isn't funny", chatFilterPlugin.censorMessage("73 isn't funny"));
@@ -102,8 +103,8 @@ public class ChatFilterPluginTest
@Test
public void testCaseSensitivity()
{
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_MESSAGE);
when(chatFilterConfig.filteredWords()).thenReturn("ReGeX!!!");
chatFilterPlugin.setFilterType(ChatFilterType.CENSOR_MESSAGE);
chatFilterPlugin.setFilteredWords("ReGeX!!!");
chatFilterPlugin.updateFilteredPatterns();
assertEquals("Hey, everyone, I just tried to say something very silly!",
@@ -113,8 +114,8 @@ public class ChatFilterPluginTest
@Test
public void testNonPrintableCharacters()
{
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE);
when(chatFilterConfig.filteredWords()).thenReturn("test");
chatFilterPlugin.setFilterType(ChatFilterType.REMOVE_MESSAGE);
chatFilterPlugin.setFilteredWords("test");
chatFilterPlugin.updateFilteredPatterns();
assertNull(chatFilterPlugin.censorMessage("te\u008Cst"));
@@ -124,7 +125,7 @@ public class ChatFilterPluginTest
public void testMessageFromFriendIsFiltered()
{
when(client.isFriended("Iron Mammal", false)).thenReturn(true);
when(chatFilterConfig.filterFriends()).thenReturn(true);
chatFilterPlugin.setFilterFriends(true);
assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("Iron Mammal"));
}
@@ -132,7 +133,7 @@ public class ChatFilterPluginTest
public void testMessageFromFriendIsNotFiltered()
{
when(client.isFriended("Iron Mammal", false)).thenReturn(true);
when(chatFilterConfig.filterFriends()).thenReturn(false);
chatFilterPlugin.setFilterFriends(false);
assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("Iron Mammal"));
}
@@ -140,7 +141,7 @@ public class ChatFilterPluginTest
public void testMessageFromClanIsFiltered()
{
when(client.isClanMember("B0aty")).thenReturn(true);
when(chatFilterConfig.filterClan()).thenReturn(true);
chatFilterPlugin.setFilterClan(true);
assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("B0aty"));
}
@@ -148,7 +149,7 @@ public class ChatFilterPluginTest
public void testMessageFromClanIsNotFiltered()
{
when(client.isClanMember("B0aty")).thenReturn(true);
when(chatFilterConfig.filterClan()).thenReturn(false);
chatFilterPlugin.setFilterClan(false);
assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("B0aty"));
}

View File

@@ -115,7 +115,8 @@ public class CookingPluginTest
Player player = mock(Player.class);
when(player.getSpotAnimation()).thenReturn(GraphicID.WINE_MAKE);
when(config.fermentTimer()).thenReturn(true);
cookingPlugin.setFermentTimer(true);
when(client.getLocalPlayer()).thenReturn(player);
SpotAnimationChanged graphicChanged = new SpotAnimationChanged();

View File

@@ -114,12 +114,12 @@ public class IdleNotifierPluginTest
when(client.getLocalPlayer()).thenReturn(player);
// Mock config
when(config.logoutIdle()).thenReturn(true);
when(config.animationIdle()).thenReturn(true);
when(config.interactionIdle()).thenReturn(true);
when(config.getIdleNotificationDelay()).thenReturn(0);
when(config.getHitpointsThreshold()).thenReturn(42);
when(config.getPrayerThreshold()).thenReturn(42);
plugin.setLogoutIdle(true);
plugin.setAnimationIdle(true);
plugin.setInteractionIdle(true);
plugin.setGetIdleNotificationDelay(0);
plugin.setGetHitpointsThreshold(42);
plugin.setGetPrayerThreshold(42);
// Mock client
when(client.getGameState()).thenReturn(GameState.LOGGED_IN);
@@ -135,10 +135,10 @@ public class IdleNotifierPluginTest
AnimationChanged animationChanged = new AnimationChanged();
animationChanged.setActor(player);
plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!");
}
@@ -149,13 +149,13 @@ public class IdleNotifierPluginTest
AnimationChanged animationChanged = new AnimationChanged();
animationChanged.setActor(player);
plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
when(player.getAnimation()).thenReturn(AnimationID.LOOKING_INTO);
plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any());
}
@@ -166,7 +166,7 @@ public class IdleNotifierPluginTest
AnimationChanged animationChanged = new AnimationChanged();
animationChanged.setActor(player);
plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
// Logout
when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN);
@@ -182,7 +182,7 @@ public class IdleNotifierPluginTest
// Tick
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any());
}
@@ -191,10 +191,10 @@ public class IdleNotifierPluginTest
{
when(player.getInteracting()).thenReturn(monster);
plugin.onInteractingChanged(new InteractingChanged(player, monster));
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
when(player.getInteracting()).thenReturn(null);
plugin.onInteractingChanged(new InteractingChanged(player, null));
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier).notify("[" + PLAYER_NAME + "] is now out of combat!");
}
@@ -203,13 +203,13 @@ public class IdleNotifierPluginTest
{
when(player.getInteracting()).thenReturn(monster);
plugin.onInteractingChanged(new InteractingChanged(player, monster));
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
when(player.getInteracting()).thenReturn(randomEvent);
plugin.onInteractingChanged(new InteractingChanged(player, randomEvent));
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
when(player.getInteracting()).thenReturn(null);
plugin.onInteractingChanged(new InteractingChanged(player, null));
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any());
}
@@ -218,7 +218,7 @@ public class IdleNotifierPluginTest
{
plugin.onInteractingChanged(new InteractingChanged(player, monster));
when(player.getInteracting()).thenReturn(monster);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
// Logout
when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN);
@@ -234,7 +234,7 @@ public class IdleNotifierPluginTest
// Tick
when(player.getInteracting()).thenReturn(null);
plugin.onInteractingChanged(new InteractingChanged(player, null));
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any());
}
@@ -249,7 +249,7 @@ public class IdleNotifierPluginTest
hitsplatApplied.setActor(player);
hitsplatApplied.setHitsplat(new Hitsplat(Hitsplat.HitsplatType.DAMAGE, 0, 0));
plugin.onHitsplatApplied(hitsplatApplied);
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any());
}
@@ -262,22 +262,22 @@ public class IdleNotifierPluginTest
when(client.getKeyboardIdleTicks()).thenReturn(80_000);
when(client.getMouseIdleTicks()).thenReturn(14_500);
plugin.onGameTick(new GameTick());
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(1)).notify(any());
}
@Test
public void testSpecRegen()
{
when(config.getSpecEnergyThreshold()).thenReturn(50);
plugin.setGetSpecEnergyThreshold(50);
when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(400); // 40%
plugin.onGameTick(new GameTick()); // once to set lastSpecEnergy to 400
plugin.onGameTick(GameTick.INSTANCE); // once to set lastSpecEnergy to 400
verify(notifier, never()).notify(any());
when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(500); // 50%
plugin.onGameTick(new GameTick());
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier).notify(Matchers.eq("[" + PLAYER_NAME + "] has restored spec energy!"));
}
}

View File

@@ -37,7 +37,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import static org.mockito.Mockito.when;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
@@ -67,7 +66,7 @@ public class NpcIndicatorsPluginTest
@Test
public void getHighlights()
{
when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin, , zulrah , *wyvern, ,");
npcIndicatorsPlugin.setGetNpcToHighlight("goblin, , zulrah , *wyvern, ,");
final List<String> highlightedNpcs = npcIndicatorsPlugin.getHighlights();
assertEquals("Length of parsed NPCs is incorrect", 3, highlightedNpcs.size());

View File

@@ -101,10 +101,10 @@ public class ScreenshotPluginTest
public void before()
{
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
when(screenshotConfig.screenshotRewards()).thenReturn(true);
when(screenshotConfig.screenshotLevels()).thenReturn(true);
when(screenshotConfig.screenshotValuableDrop()).thenReturn(true);
when(screenshotConfig.screenshotUntradeableDrop()).thenReturn(true);
screenshotPlugin.setScreenshotRewards(true);
screenshotPlugin.setScreenshotLevels(true);
screenshotPlugin.setScreenshotValuableDrop(true);
screenshotPlugin.setScreenshotUntradeableDrop(true);
}
@Test
@@ -179,7 +179,7 @@ public class ScreenshotPluginTest
event.setGroupId(LEVEL_UP_GROUP_ID);
screenshotPlugin.onWidgetLoaded(event);
GameTick tick = new GameTick();
GameTick tick = GameTick.INSTANCE;
screenshotPlugin.onGameTick(tick);
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
@@ -202,7 +202,7 @@ public class ScreenshotPluginTest
event.setGroupId(LEVEL_UP_GROUP_ID);
screenshotPlugin.onWidgetLoaded(event);
GameTick tick = new GameTick();
GameTick tick = GameTick.INSTANCE;
screenshotPlugin.onGameTick(tick);
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
@@ -225,7 +225,7 @@ public class ScreenshotPluginTest
event.setGroupId(LEVEL_UP_GROUP_ID);
screenshotPlugin.onWidgetLoaded(event);
GameTick tick = new GameTick();
GameTick tick = GameTick.INSTANCE;
screenshotPlugin.onGameTick(tick);
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
@@ -248,7 +248,7 @@ public class ScreenshotPluginTest
event.setGroupId(DIALOG_SPRITE_GROUP_ID);
screenshotPlugin.onWidgetLoaded(event);
GameTick tick = new GameTick();
GameTick tick = GameTick.INSTANCE;
screenshotPlugin.onGameTick(tick);
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));

View File

@@ -155,7 +155,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(231, slayerPlugin.getCurrentTask().getAmount());
@@ -167,7 +167,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Wyrms", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(147, slayerPlugin.getCurrentTask().getAmount());
@@ -180,7 +180,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_2);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Hellhounds", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(142, slayerPlugin.getCurrentTask().getAmount());
@@ -193,7 +193,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_3);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Trolls", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(135, slayerPlugin.getCurrentTask().getAmount());
@@ -206,7 +206,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_FIRST);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("goblins", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(17, slayerPlugin.getCurrentTask().getAmount());
@@ -218,7 +218,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_NPC_CONTACT);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(211, slayerPlugin.getCurrentTask().getAmount());
@@ -230,7 +230,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Vet'ion", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(3, slayerPlugin.getCurrentTask().getAmount());
@@ -243,7 +243,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW_THE);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Chaos Elemental", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(3, slayerPlugin.getCurrentTask().getAmount());
@@ -296,7 +296,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_EXISTING);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("suqahs", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(222, slayerPlugin.getCurrentTask().getAmount());
@@ -387,11 +387,11 @@ public class SlayerPluginTest
{
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Superior", SUPERIOR_MESSAGE, null, 0);
when(slayerConfig.showSuperiorNotification()).thenReturn(true);
slayerPlugin.setShowSuperiorNotification(true);
slayerPlugin.onChatMessage(chatMessageEvent);
verify(notifier).notify(SUPERIOR_MESSAGE);
when(slayerConfig.showSuperiorNotification()).thenReturn(false);
slayerPlugin.setShowSuperiorNotification(false);
slayerPlugin.onChatMessage(chatMessageEvent);
verifyNoMoreInteractions(notifier);
}
@@ -405,7 +405,7 @@ public class SlayerPluginTest
task.setAmount(42);
task.setInitialAmount(42);
when(slayerConfig.taskCommand()).thenReturn(true);
slayerPlugin.setTaskCommand(true);
when(chatClient.getTask(anyString())).thenReturn(task);
ChatMessage setMessage = new ChatMessage();

View File

@@ -86,7 +86,7 @@ public class TimersPluginTest
@Test
public void testHalfTeleblock()
{
when(timersConfig.showTeleblock()).thenReturn(true);
timersPlugin.setShowTeleblock(true);
when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.MEMBERS));
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", HALF_TELEBLOCK_MESSAGE, "", 0);
timersPlugin.onChatMessage(chatMessage);
@@ -100,7 +100,7 @@ public class TimersPluginTest
@Test
public void testFullTeleblock()
{
when(timersConfig.showTeleblock()).thenReturn(true);
timersPlugin.setShowTeleblock(true);
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", FULL_TELEBLOCK_MESSAGE, "", 0);
timersPlugin.onChatMessage(chatMessage);
@@ -113,7 +113,7 @@ public class TimersPluginTest
@Test
public void testDmmHalfTb()
{
when(timersConfig.showTeleblock()).thenReturn(true);
timersPlugin.setShowTeleblock(true);
when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.DEADMAN));
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", DMM_HALF_TELEBLOCK_MESSAGE, "", 0);
timersPlugin.onChatMessage(chatMessage);
@@ -127,7 +127,7 @@ public class TimersPluginTest
@Test
public void testDmmFullTb()
{
when(timersConfig.showTeleblock()).thenReturn(true);
timersPlugin.setShowTeleblock(true);
when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.DEADMAN));
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", HALF_TELEBLOCK_MESSAGE, "", 0);
timersPlugin.onChatMessage(chatMessage);