net.runelite.api.events.GameStateChanged Java Examples
The following examples show how to use
net.runelite.api.events.GameStateChanged.
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: EmojiPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@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)); // Trip emoji loading GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGGED_IN); emojiPlugin.onGameStateChanged(gameStateChanged); MessageNode messageNode = mock(MessageNode.class); // With chat recolor, message may be wrapped in col tags 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>"); }
Example #2
Source File: AgilityPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onGameStateChanged(GameStateChanged event) { switch (event.getGameState()) { case HOPPING: case LOGIN_SCREEN: session = null; lastArenaTicketPosition = null; removeAgilityArenaTimer(); npcs.clear(); break; case LOADING: marksOfGrace.clear(); obstacles.clear(); stickTile = null; break; case LOGGED_IN: if (!isInAgilityArena()) { lastArenaTicketPosition = null; removeAgilityArenaTimer(); } break; } }
Example #3
Source File: ReportButtonPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { GameState state = event.getGameState(); switch (state) { case LOGGING_IN: case HOPPING: case CONNECTION_LOST: ready = true; break; case LOGGED_IN: if (ready) { loginTime = Instant.now(); ticksSinceLogin = 0; ready = false; } break; } }
Example #4
Source File: MotherlodePlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOADING) { // on region changes the tiles get set to null veins.clear(); rocks.clear(); inMlm = checkInMlm(); } else if (event.getGameState() == GameState.LOGIN_SCREEN) { // Prevent code from running while logged out. inMlm = false; } }
Example #5
Source File: ObjectIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { GameState gameState = gameStateChanged.getGameState(); if (gameState == GameState.LOADING) { // Reload points with new map regions points.clear(); for (int regionId : client.getMapRegions()) { // load points for region final Set<ObjectPoint> regionPoints = loadPoints(regionId); if (regionPoints != null) { points.put(regionId, regionPoints); } } } if (gameStateChanged.getGameState() != GameState.LOGGED_IN) { objects.clear(); } }
Example #6
Source File: RaidsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { if (client.getGameState() == GameState.LOGGED_IN) { // skip event while the game decides if the player belongs in a raid or not if (client.getLocalPlayer() == null || client.getLocalPlayer().getWorldLocation().equals(TEMP_LOCATION)) { return; } checkInRaid = true; } else if (client.getGameState() == GameState.LOGIN_SCREEN || client.getGameState() == GameState.CONNECTION_LOST) { loggedIn = false; } else if (client.getGameState() == GameState.HOPPING) { reset(); } }
Example #7
Source File: EmojiPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testGtLt() { when(client.getGameState()).thenReturn(GameState.LOGGED_IN); when(client.getModIcons()).thenReturn(new IndexedSprite[0]); when(client.createIndexedSprite()).thenReturn(mock(IndexedSprite.class)); // Trip emoji loading GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGGED_IN); emojiPlugin.onGameStateChanged(gameStateChanged); MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn("<gt>:D<lt>"); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setMessageNode(messageNode); emojiPlugin.onChatMessage(chatMessage); verify(messageNode).setRuneLiteFormatMessage("<img=10>"); }
Example #8
Source File: RunecraftPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { GameState gameState = event.getGameState(); switch (gameState) { case LOADING: abyssObjects.clear(); break; case CONNECTION_LOST: case HOPPING: case LOGIN_SCREEN: darkMage = null; break; } }
Example #9
Source File: SlayerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { switch (event.getGameState()) { case HOPPING: case LOGGING_IN: cachedXp = -1; taskName = ""; amount = 0; loginFlag = true; highlightedTargets.clear(); break; case LOGGED_IN: if (config.amount() != -1 && !config.taskName().isEmpty() && loginFlag) { setExpeditiousChargeCount(config.expeditious()); setSlaughterChargeCount(config.slaughter()); setTask(config.taskName(), config.amount(), config.initialAmount(), config.taskLocation(), false); loginFlag = false; } break; } }
Example #10
Source File: MotherlodePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOADING) { // on region changes the tiles get set to null veins.clear(); rocks.clear(); inMlm = checkInMlm(); } else if (event.getGameState() == GameState.LOGIN_SCREEN) { // Prevent code from running while logged out. inMlm = false; } }
Example #11
Source File: SpecialCounterPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGGED_IN) { if (currentWorld == -1) { currentWorld = client.getWorld(); } else if (currentWorld != client.getWorld()) { currentWorld = client.getWorld(); removeCounters(); } } }
Example #12
Source File: MiningPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onGameStateChanged(GameStateChanged event) { switch (event.getGameState()) { case HOPPING: respawns.clear(); break; case LOGGED_IN: // After login rocks that are depleted will be changed, // so wait for the next game tick before watching for // rocks to deplete recentlyLoggedIn = true; break; } }
Example #13
Source File: KingdomPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { if (client.getGameState() == GameState.LOGGED_IN && (isInKingdom() || config.showInfoboxAnywhere())) { if (!royalTrouble || !throneOfMiscellania) { clientThread.invokeLater(this::hasCompletedQuests); } if (throneOfMiscellania || royalTrouble) { updateKingdomVarbits(); setKingdomResourceDistribution(); kingdomManagement(personalKingdom); kingdomManagement(maxKingdom); addKingdomInfobox(); notifyFavor(); notifyCoffer(); } } if (client.getGameState() == GameState.LOGGED_IN && (!isInKingdom() && !config.showInfoboxAnywhere())) { removeKingdomInfobox(); } }
Example #14
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 #15
Source File: WoodcuttingPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameStateChanged(final GameStateChanged event) { switch (event.getGameState()) { case HOPPING: respawns.clear(); case LOADING: treeObjects.clear(); break; case LOGGED_IN: // After login trees that are depleted will be changed, // wait for the next game tick before watching for // trees to despawn recentlyLoggedIn = true; break; } }
Example #16
Source File: SlayerPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe void onGameStateChanged(GameStateChanged event) { switch (event.getGameState()) { case HOPPING: case LOGGING_IN: cachedXp = -1; cachedPoints = 0; clearTrackedNPCs(); break; case LOGIN_SCREEN: currentTask.setPaused(true); break; case LOGGED_IN: if (config.amount() != -1 && !config.taskName().isEmpty() && currentTask.getTaskName() == null) { setTask(config.taskName(), config.amount(), config.initialAmount(), true, config.taskLocation(), config.lastCertainAmount(), false); } } }
Example #17
Source File: WoodcuttingPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onGameStateChanged(final GameStateChanged event) { switch (event.getGameState()) { case HOPPING: respawns.clear(); case LOADING: treeObjects.clear(); break; case LOGGED_IN: // After login trees that are depleted will be changed, // wait for the next game tick before watching for // trees to despawn recentlyLoggedIn = true; break; } }
Example #18
Source File: EmojiPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@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)); // Trip emoji loading GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGGED_IN); emojiPlugin.onGameStateChanged(gameStateChanged); MessageNode messageNode = mock(MessageNode.class); // With chat recolor, message may be wrapped in col tags 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>"); }
Example #19
Source File: XpTrackerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testOfflineXp() { GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOGGING_IN); // Flag initialization of tracker xpTrackerPlugin.onGameStateChanged(gameStateChanged); when(client.getSkillExperience(Skill.ATTACK)).thenReturn(42); // Initialize tracker xpTrackerPlugin.onGameTick(new GameTick()); // Gain attack xp StatChanged statChanged = new StatChanged( Skill.ATTACK, 100, 2, 2 ); xpTrackerPlugin.onStatChanged(statChanged); // Offline gain when(client.getSkillExperience(Skill.ATTACK)).thenReturn(42000); // Flag initialization of tracker xpTrackerPlugin.onGameStateChanged(gameStateChanged); // Initialize tracker xpTrackerPlugin.onGameTick(new GameTick()); // Start at 42 xp, gain of 58 xp, offline gain of 41900 xp - offset start XP: 42 + 41900 XpStateSingle skillState = xpTrackerPlugin.getSkillState(Skill.ATTACK); assertEquals(41942, skillState.getStartXp()); }
Example #20
Source File: ImplingsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) { implings.clear(); } }
Example #21
Source File: DefaultWorldPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe(takeUntil = 2) private void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGGED_IN) { config.lastWorld(client.getWorld()); } applyWorld(); }
Example #22
Source File: AttackStylesPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGGED_IN) { resetWarnings(); } }
Example #23
Source File: CorpPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGameStateChanged(GameStateChanged gameStateChanged) { if (gameStateChanged.getGameState() == GameState.LOADING) { players.clear(); } }
Example #24
Source File: CorpPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { if (gameStateChanged.getGameState() == GameState.LOADING) { players.clear(); } }
Example #25
Source File: NpcAggroAreaPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGameStateChanged(GameStateChanged event) { switch (event.getGameState()) { case LOGGED_IN: if (loggingIn) { loggingIn = false; onLogin(); } recheckActive(); break; case LOGGING_IN: loggingIn = true; break; case LOGIN_SCREEN: if (lastPlayerLocation != null) { saveConfig(); } safeCenters[0] = null; safeCenters[1] = null; lastPlayerLocation = null; break; } }
Example #26
Source File: MouseHighlightPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGGED_IN) { adjustTips(); } }
Example #27
Source File: NpcIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) { highlightedNpcs.clear(); deadNpcsToDisplay.clear(); memorizedNpcs.forEach((id, npc) -> npc.setDiedOnTick(-1)); lastPlayerLocation = null; skipNextSpawnCheck = true; } }
Example #28
Source File: NpcStatusPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) { memorizedNPCs.clear(); } }
Example #29
Source File: AlchemyRoom.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { if (gameStateChanged.getGameState() == GameState.LOGGED_IN) { if (!inside()) { reset(); } } }
Example #30
Source File: GrandExchangePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN) { panel.getOffersPanel().resetOffers(); loginBurstGeUpdates = true; } }