net.runelite.api.events.GameTick Java Examples
The following examples show how to use
net.runelite.api.events.GameTick.
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: ScreenshotPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testAttackLevel70() { Widget levelChild = mock(Widget.class); when(client.getWidget(eq(LEVEL_UP_LEVEL))).thenReturn(levelChild); when(levelChild.getText()).thenReturn("Your Attack level is now 70."); assertEquals("Attack(70)", screenshotPlugin.parseLevelUpWidget(client.getWidget(LEVEL_UP_LEVEL))); WidgetLoaded event = new WidgetLoaded(); event.setGroupId(LEVEL_UP_GROUP_ID); screenshotPlugin.onWidgetLoaded(event); GameTick tick = GameTick.INSTANCE; screenshotPlugin.onGameTick(tick); verify(drawManager).requestNextFrameListener(any(Consumer.class)); }
Example #2
Source File: ScreenshotPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testHitpointsLevel99() { Widget levelChild = mock(Widget.class); when(client.getWidget(eq(LEVEL_UP_LEVEL))).thenReturn(levelChild); when(levelChild.getText()).thenReturn("Your Hitpoints are now 99."); assertEquals("Hitpoints(99)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL)); WidgetLoaded event = new WidgetLoaded(); event.setGroupId(LEVEL_UP_GROUP_ID); screenshotPlugin.onWidgetLoaded(event); GameTick tick = new GameTick(); screenshotPlugin.onGameTick(tick); verify(drawManager).requestNextFrameListener(any(Consumer.class)); }
Example #3
Source File: IdleNotifierPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void checkAnimationReset() { when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE); AnimationChanged animationChanged = new AnimationChanged(); animationChanged.setActor(player); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(GameTick.INSTANCE); when(player.getAnimation()).thenReturn(AnimationID.LOOKING_INTO); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(GameTick.INSTANCE); when(player.getAnimation()).thenReturn(AnimationID.IDLE); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); }
Example #4
Source File: PyramidPlunderPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameTick(GameTick tick) { if (isInPyramidPlunder()) { if (timer == null) { int ppTimer = client.getVar(Varbits.PYRAMID_PLUNDER_TIMER); Duration remaining = PYRAMID_PLUNDER_DURATION.minus(ppTimer, RSTimeUnit.GAME_TICKS); timer = new PyramidPlunderTimer(remaining, itemManager.getImage(PHARAOHS_SCEPTRE), this, config, client); infoBoxManager.addInfoBox(timer); } } else if (timer != null) { infoBoxManager.removeInfoBox(timer); timer = null; } }
Example #5
Source File: BlastFurnacePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onGameTick(GameTick event) { Widget npcDialog = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT); if (npcDialog == null) { return; } // blocking dialog check until 5 minutes needed to avoid re-adding while dialog message still displayed boolean shouldCheckForemanFee = client.getRealSkillLevel(Skill.SMITHING) < 60 && (foremanTimer == null || Duration.between(Instant.now(), foremanTimer.getEndTime()).toMinutes() <= 5); if (shouldCheckForemanFee) { String npcText = Text.sanitizeMultilineText(npcDialog.getText()); if (npcText.equals(FOREMAN_PERMISSION_TEXT)) { infoBoxManager.removeIf(ForemanTimer.class::isInstance); foremanTimer = new ForemanTimer(this, itemManager); infoBoxManager.addInfoBox(foremanTimer); } } }
Example #6
Source File: Anonymizer.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onGameTick(GameTick event) { Player p = client.getLocalPlayer(); if (p == null) { return; } name = p.getName(); if (config.hideXp()) { Widget xp = client.getWidget(122, 9); if (xp != null && xp.getText() != null && !xp.isHidden()) { xp.setText("123,456,789"); xp.revalidate(); } } }
Example #7
Source File: IdleNotifierPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void checkCombatLogout() { plugin.onInteractingChanged(new InteractingChanged(player, monster)); when(player.getInteracting()).thenReturn(mock(Actor.class)); plugin.onGameTick(new GameTick()); // Logout when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN); GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGIN_SCREEN); plugin.onGameStateChanged(gameStateChanged); // Log back in when(client.getGameState()).thenReturn(GameState.LOGGED_IN); gameStateChanged.setGameState(GameState.LOGGED_IN); plugin.onGameStateChanged(gameStateChanged); // Tick plugin.onInteractingChanged(new InteractingChanged(player, null)); plugin.onGameTick(new GameTick()); verify(notifier, times(0)).notify(any()); }
Example #8
Source File: ShayzienInfirmaryPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onGameTick(GameTick event) { if (isNotAtInfirmary()) { return; } unhealedSoldiers.clear(); for (NPC npc : client.getNpcs()) { if (isUnhealedSoldierId(npc.getId())) { unhealedSoldiers.add(npc); } } }
Example #9
Source File: ScreenshotPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testFiremakingLevel9() { Widget levelChild = mock(Widget.class); when(client.getWidget(eq(LEVEL_UP_LEVEL))).thenReturn(levelChild); when(levelChild.getText()).thenReturn("Your Firemaking level is now 9."); assertEquals("Firemaking(9)", screenshotPlugin.parseLevelUpWidget(client.getWidget(LEVEL_UP_LEVEL))); WidgetLoaded event = new WidgetLoaded(); event.setGroupId(LEVEL_UP_GROUP_ID); screenshotPlugin.onWidgetLoaded(event); GameTick tick = GameTick.INSTANCE; screenshotPlugin.onGameTick(tick); verify(drawManager).requestNextFrameListener(any(Consumer.class)); }
Example #10
Source File: ScreenshotPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testHunterLevel2() { Widget levelChild = mock(Widget.class); when(client.getWidget(eq(DIALOG_SPRITE_TEXT))).thenReturn(levelChild); when(levelChild.getText()).thenReturn("<col=000080>Congratulations, you've just advanced a Hunter level.<col=000000><br><br>Your Hunter level is now 2."); assertEquals("Hunter(2)", screenshotPlugin.parseLevelUpWidget(client.getWidget(DIALOG_SPRITE_TEXT))); WidgetLoaded event = new WidgetLoaded(); event.setGroupId(DIALOG_SPRITE_GROUP_ID); screenshotPlugin.onWidgetLoaded(event); GameTick tick = GameTick.INSTANCE; screenshotPlugin.onGameTick(tick); verify(drawManager).requestNextFrameListener(any(Consumer.class)); }
Example #11
Source File: WintertodtPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onGameTick(GameTick gameTick) { if (!isInWintertodtRegion()) { if (isInWintertodt) { log.debug("Left Wintertodt!"); reset(); } isInWintertodt = false; return; } if (!isInWintertodt) { reset(); log.debug("Entered Wintertodt!"); } isInWintertodt = true; checkActionTimeout(); }
Example #12
Source File: VirtualLevelsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onGameTick(GameTick event) { if (input != null) { input.closeIfTriggered(); } if (skillsLeveledUp.isEmpty() || !chatboxPanelManager.getContainerWidget().isHidden()) { return; } final Skill skill = skillsLeveledUp.remove(0); input = new VirtualLevelsInterfaceInput(this, skill); chatboxPanelManager.openInput(input); }
Example #13
Source File: IdleNotifierPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void checkAnimationReset() { when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE); AnimationChanged animationChanged = new AnimationChanged(); animationChanged.setActor(player); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(new GameTick()); when(player.getAnimation()).thenReturn(AnimationID.LOOKING_INTO); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(new GameTick()); when(player.getAnimation()).thenReturn(AnimationID.IDLE); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(new GameTick()); verify(notifier, times(0)).notify(any()); }
Example #14
Source File: RunecraftPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateConfig() { if (config.degradeOverlay()) { overlayManager.add(pouchOverlay); eventBus.subscribe(GameTick.class, POUCH_TICK, this::onGameTick); } else { overlayManager.remove(pouchOverlay); eventBus.unregister(POUCH_TICK); } updateRifts(); }
Example #15
Source File: ChatCommandsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@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); when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + "not the player"); when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); WidgetLoaded advLogEvent = new WidgetLoaded(); advLogEvent.setGroupId(ADVENTURE_LOG_ID); chatCommandsPlugin.onWidgetLoaded(advLogEvent); chatCommandsPlugin.onGameTick(new GameTick()); WidgetLoaded countersLogEvent = new WidgetLoaded(); countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); chatCommandsPlugin.onWidgetLoaded(countersLogEvent); chatCommandsPlugin.onGameTick(new GameTick()); verifyNoMoreInteractions(configManager); }
Example #16
Source File: AgilityPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onGameTick(GameTick tick) { if (isInAgilityArena()) { // Hint arrow has no plane, and always returns the current plane WorldPoint newTicketPosition = client.getHintArrowPoint(); WorldPoint oldTickPosition = lastArenaTicketPosition; lastArenaTicketPosition = newTicketPosition; if (oldTickPosition != null && newTicketPosition != null && (oldTickPosition.getX() != newTicketPosition.getX() || oldTickPosition.getY() != newTicketPosition.getY())) { if (config.notifyAgilityArena()) { notifier.notify("Ticket location changed"); } if (config.showAgilityArenaTimer()) { showNewAgilityArenaTimer(); } } } }
Example #17
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testNewKonarTask2() { 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()); assertEquals("Hellhounds", slayerPlugin.getTaskName()); assertEquals(142, slayerPlugin.getAmount()); assertEquals("Witchhaven Dungeon", slayerPlugin.getTaskLocation()); }
Example #18
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testFirstTask() { 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()); assertEquals("goblins", slayerPlugin.getTaskName()); assertEquals(17, slayerPlugin.getAmount()); }
Example #19
Source File: FishingPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGameTick(GameTick event) { // Reset fishing session if (session.getLastFishCaught() != null) { final Duration statTimeout = Duration.ofMinutes(config.statTimeout()); final Duration sinceCaught = Duration.between(session.getLastFishCaught(), Instant.now()); if (sinceCaught.compareTo(statTimeout) >= 0) { currentSpot = null; session.setLastFishCaught(null); } } inverseSortSpotDistanceFromPlayer(); for (NPC npc : fishingSpots) { if (FishingSpot.findSpot(npc.getId()) == FishingSpot.MINNOW && config.showMinnowOverlay()) { final int id = npc.getIndex(); final MinnowSpot minnowSpot = minnowSpots.get(id); // create the minnow spot if it doesn't already exist // or if it was moved, reset it if (minnowSpot == null || !minnowSpot.getLoc().equals(npc.getWorldLocation())) { minnowSpots.put(id, new MinnowSpot(npc.getWorldLocation(), Instant.now())); } } } if (config.trawlerTimer()) { updateTrawlerTimer(); } }
Example #20
Source File: IdleNotifierPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void checkCombatReset() { when(player.getInteracting()).thenReturn(mock(Actor.class)); plugin.onInteractingChanged(new InteractingChanged(player, monster)); plugin.onGameTick(new GameTick()); plugin.onInteractingChanged(new InteractingChanged(player, randomEvent)); plugin.onGameTick(new GameTick()); plugin.onInteractingChanged(new InteractingChanged(player, null)); plugin.onGameTick(new GameTick()); verify(notifier, times(0)).notify(any()); }
Example #21
Source File: XpDropPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameTick(GameTick tick) { currentTickPrayer = getActivePrayerType(); correctPrayer = false; final int fakeTickDelay = config.fakeXpDropDelay(); if (fakeTickDelay == 0 || lastSkill == null) { return; } // If an xp drop was created this tick, reset the counter if (hasDropped) { hasDropped = false; tickCounter = 0; return; } if (++tickCounter % fakeTickDelay != 0) { return; } client.runScript(XPDROP_DISABLED, lastSkill.ordinal(), previousExpGained); }
Example #22
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testExistingTaskWilderness() { Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_EXISTING_WILDERNESS); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); slayerPlugin.onGameTick(new GameTick()); assertEquals("bandits", slayerPlugin.getTaskName()); assertEquals(99, slayerPlugin.getAmount()); assertEquals("Wilderness", slayerPlugin.getTaskLocation()); }
Example #23
Source File: TimersPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameTick(GameTick event) { loggedInRace = false; Player player = client.getLocalPlayer(); WorldPoint currentWorldPoint = player.getWorldLocation(); if (freezeTimer != null) { // assume movement means unfrozen if (freezeTime != client.getTickCount() && !currentWorldPoint.equals(lastPoint)) { removeGameTimer(freezeTimer.getTimer()); freezeTimer = null; } } lastPoint = currentWorldPoint; if (!widgetHiddenChangedOnPvpWorld) { return; } widgetHiddenChangedOnPvpWorld = false; Widget widget = client.getWidget(PVP_WORLD_SAFE_ZONE); if (widget != null && !widget.isSelfHidden()) { log.debug("Entered safe zone in PVP world, clearing Teleblock timer."); removeTbTimers(); } }
Example #24
Source File: OpponentInfoPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameTick(GameTick gameTick) { if (lastOpponent != null && lastTime != null && client.getLocalPlayer().getInteracting() == null) { if (Duration.between(lastTime, Instant.now()).compareTo(WAIT) > 0) { lastOpponent = null; } } }
Example #25
Source File: NpcIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameTick(GameTick event) { removeOldHighlightedRespawns(); validateSpawnedNpcs(); lastTickUpdate = Instant.now(); lastPlayerLocation = client.getLocalPlayer().getWorldLocation(); }
Example #26
Source File: ZalcanoPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void onGameTickCheckRegion(GameTick gameTick) { if (util.isInZalcanoRegion()) { log.debug("region check complete loading other events"); util.manuallyFindZalcano(); //this is here because the new subscribed npcspawn doesn't catch a pre existing zalcano overlayManager.add(overlay); overlayManager.add(stepsOverlay); eventBus.unregister("regionchecker"); } }
Example #27
Source File: ClueScrollPluginTest.java From plugins with GNU General Public License v3.0 | 5 votes |
@Test public void testLocationHintArrowCleared() { final Widget clueWidget = mock(Widget.class); when(clueWidget.getText()).thenReturn("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Reldo may have a clue."); final ChatMessage hotColdMessage = new ChatMessage(); hotColdMessage.setType(ChatMessageType.GAMEMESSAGE); final Player localPlayer = mock(Player.class); when(client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT)).thenReturn(clueWidget); when(client.getLocalPlayer()).thenReturn(localPlayer); when(client.getPlane()).thenReturn(0); when(client.getCachedNPCs()).thenReturn(new NPC[]{}); // The hint arrow should be reset each game tick from when the clue is read onward // This is to verify the arrow is cleared the correct number of times during the clue updating process. int clueSetupHintArrowClears = 0; // Perform the first hot-cold check in Lumbridge near sheep pen (get 2 possible points: LUMBRIDGE_COW_FIELD and DRAYNOR_WHEAT_FIELD) when(localPlayer.getWorldLocation()).thenReturn(new WorldPoint(3208, 3254, 0)); hotColdMessage.setMessage("The device is hot."); plugin.onChatMessage(hotColdMessage); // Move to SW of DRAYNOR_WHEAT_FIELD (hint arrow should be visible here) when(localPlayer.getWorldLocation()).thenReturn(new WorldPoint(3105, 3265, 0)); when(client.getBaseX()).thenReturn(3056); when(client.getBaseY()).thenReturn(3216); plugin.onGameTick(GameTick.INSTANCE); // Test in that location (get 1 possible location: LUMBRIDGE_COW_FIELD) hotColdMessage.setMessage("The device is hot, and warmer than last time."); plugin.onChatMessage(hotColdMessage); plugin.onGameTick(GameTick.INSTANCE); }
Example #28
Source File: NeverLogoutPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGametick(GameTick gameTick) { if (client.getKeyboardIdleTicks() > 14900) { client.setKeyboardIdleTicks(0); } if (client.getMouseIdleTicks() > 14900) { client.setMouseIdleTicks(0); } }
Example #29
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testSlayergemActivateKonar() { Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_ACTIVATESLAYERGEM_KONAR); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); slayerPlugin.onGameTick(new GameTick()); assertEquals("adamant dragons", slayerPlugin.getTaskName()); assertEquals(3, slayerPlugin.getAmount()); assertEquals("Lithkren Vault", slayerPlugin.getTaskLocation()); }
Example #30
Source File: WoodcuttingPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGameTick(GameTick gameTick) { recentlyLoggedIn = false; currentPlane = client.getPlane(); respawns.removeIf(TreeRespawn::isExpired); if (session == null || session.getLastChopping() == null) { return; } if (axe != null && axe.matchesChoppingAnimation(client.getLocalPlayer())) { session.setLastChopping(); return; } Duration statTimeout = Duration.ofMinutes(config.statTimeout()); Duration sinceCut = Duration.between(session.getLastChopping(), Instant.now()); if (sinceCut.compareTo(statTimeout) >= 0) { session = null; axe = null; } }