plugins: reduce config calls by saving and reusing values, misc performance tweaks. (#799)

* Save config values -- AgilityPlugin

* Static state value map

* Don't run area in the for loop

* Checking for bounds is enough for widget null check

* Cache font settings

* SAve config values -- AntiDragPlugin

* Save config values -- AoEPlugin

* Save config values -- AttackStylesPlugin

* Save config values -- BankPlugin

* Check if player is in kingdom

* Save hideAutoRetaliate -- AttackStylesPlugin

* Save config values -- BanListPlugin

* Save config values -- BarbaranAssaultPlugin

* Save config values -- BarrowsPlugin

* Checkstyle

* Move up updateConfig.java

* Save config values -- BlackjackPlugin

* Save config values -- BlastFurnacePlugin

* Save config values -- BlastMinePlugin

* Save config values -- BoostsPlugin

* Save config values -- CannonPlugin

* Fix bank plugin test

* Parallelize plugin loading

* Fix sidebar going AWOL

* Save config values -- ChatFilterPlugin

* Save config values -- ChatHistoryPlugin

* Save config values -- ChatNotificationsPlugin

* Save config values -- ChatTranslationPlugin

* Save config values -- ClanChatPlugin

* Save config values -- ClueScrollPlugin

* Cleanup CombatCounterPlugin

* Save config values -- CombatCounter

* Checkstyle

* Save config values -- CombatLevelPlugin

* Convert game thread events without mutable field to singletons

These should be safe to convert, events with mutable field should be checked

* Checkstyle

* Fix test

* Save config values -- CookingPlugin

* Save config values -- CorpPlugin

* SAve config values -- CoxPlugin

* Save config values -- DailyTasksPlugin

* Save config values -- DiscordPlugin

* Coxhelper checkstyle

* Save config values -- EquipmentInspectorPlugin

* SAve cofig values -- XpDropPlugin

* Save config values -- FairyRingPlugin

* Save config values -- FightCavePlugin

* Save config values -- FishingPlugin

* Save config values and refactor -- FlexoPlugin

* Save config values -- FlinchingPlugin

* Save config values -- FreezeTimersPlugin

* Save config values -- GpuPlugin

* Save config values -- GrandExchangePlugin

* Save config values -- GroundItemsPlugin

* Save config values -- GroundMarkerPlugin

* Save config values -- GroundMarkerPlugin

* Save config values -- HerbiboarPlugin

* Save config values -- HidePrayersPlugin

* Save config values -- HighAlchemyPlugin

* Save config values -- HunterPlugin

* Save config values -- BabyHydraPlugin

* Fix Flexo

* Checkstyle

* Save config values -- IdleNotifierPlugin

* Save config values -- ImplingsPlugin

* Save config values and cleanup -- InfernoPlugin

* Use EqualsAndHashCode for GroundMarkerPoint

* Save config values -- InterfaceStylesPlugin

* Save config values -- InventoryGridPlugin

* Save config values -- InventorySetupPlugin

* Checkstyle

* Save config values -- InventoryTagsPlugin

* Save config values -- InventoryViewerPlugin

* Save config values -- ItemChargePlugin

* Save config values -- ItemIdentificationPlugin

* Save config values -- ItemPricesPlugin

* Save config values -- ItemStatPlugin

* Save config values -- KeyRemappingPlugin

* Save config values -- KourendLibraryPlugin

* Save config values -- LearnToClickPlugin

* Save config values -- LizardmenShamanPlugin

* Save config values -- LoginScreenPlugin

* Cleanup LootAssistOverlay

* Remove unused LootAssistConfig

* Save config values -- LootTrackerPlugin

* Save config values -- MetronomePlugin

* Add border color ground items

* Save config values -- WorstPluginEverPlugin

* Fix inferno plugin

* Save config values -- MinimapPlugin

* Save config values -- MiningPlugin

* Save config values -- MotherlodePlugin

* Save config values -- MouseHighlightPlugin

* Save config values -- MTAPlugin

* Save config values -- MultiIndicatorsPlugin

* Save config values -- NightmareZonePlugin

* Save config values -- NpcIndicatorsPlugin

* Save config values -- NpcStatusPlugin

* Save config values -- NpcAggroAreaPlugin

* Save config values -- ObjectIndicatorsPlugin

* Save config values -- OpponentInfoPlugin

* Save config values -- PartyPlugin

* Save config values -- PerformanceStatsPlugin

* Save config values and cleanup -- PestcontrolPlugin

* Save config values , cleanup and refactor -- PileIndicatorsPlugin

* Save config values -- PlayerIndicatorsPlugin

* Save config values -- PlayerInfoPlugin

* Save config values -- PluginSorterPlugin

* Save config values -- PohPlugin

* Checkstyle

* Save config values -- PoisonPlugin

* Save config values -- PrayAgainstPlayerPlugin

* Save config values -- PrayerPlugin

* Save config values -- PrayerAlertPlugin

* Checkstyle

* Save config values -- PuzzleSolverPlugin

* Save config values -- PvpToolsPlugin

* Save config values -- PyramidPlunderPlugin

* Save config values -- RaidsPlugin

* Save config values -- ShortcutPlugin

* Save config values -- RaidsThievingPlugin

* Oopsie

* Save config values -- RegenMeterPlugin

* Save config values -- ReportButtonPlugin

* Save config values -- RunecraftPlugin

* Save config values -- RunedokuPlugin

* Save config values -- RunepouchPlugin

* Save config values -- SafeSpotPlugin

* Save config values -- ScreenshotPlugin

* Save config values -- ShiftWalkerPlugin

* Save config values -- SlayerPlugin

* Save config values -- SmeltingPlugin

* Save config values -- SpawnTimerPlugin

* Save config values -- SpellbookPlugin

* Save config values -- StatusBarsPlugin

* Save config values -- ThievingPlugin

* Checkstyle

* Cleanup Zulrah

* Save config values -- XpTrackerPlugin

* Save config values -- XpGlobesPlugin

* Save config values -- WorldMapPlugin

* Save config values -- TheatrePlugin

* Save config values -- TickTimersPlugin

* Save config values -- TileIndicatorsPlugin

* Save config values -- TimersPlugin

* Save config values -- TitheFarmPlugin

* Save config values -- TMorphPlugin

* Save config values -- WarIndicatorPlugin

* Save config values -- WhaleWatchersPlugin

* Save config values -- WildernessLocationsPlugin

* Save config values -- WintertodtPlugin

* Save config values -- WorldHopperPlugin

* Save config values -- WoodcuttingPlugin

* Cleanup

* Checkstyle

* Fix tests
This commit is contained in:
sdburns1998
2019-07-05 01:11:31 +02:00
committed by Lucwousin
parent 8f05c01618
commit 22914889aa
694 changed files with 9824 additions and 4525 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);