Java Code Examples for net.runelite.api.events.GameStateChanged#setGameState()
The following examples show how to use
net.runelite.api.events.GameStateChanged#setGameState() .
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: IdleNotifierPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void checkAnimationLogout() { when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE); AnimationChanged animationChanged = new AnimationChanged(); animationChanged.setActor(player); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(GameTick.INSTANCE); // 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 when(player.getAnimation()).thenReturn(AnimationID.IDLE); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); }
Example 2
Source File: IdleNotifierPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void checkCombatLogout() { plugin.onInteractingChanged(new InteractingChanged(player, monster)); when(player.getInteracting()).thenReturn(mock(Actor.class)); plugin.onGameTick(GameTick.INSTANCE); // 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(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); }
Example 3
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 4
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 5
Source File: IdleNotifierPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void checkAnimationLogout() { when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE); AnimationChanged animationChanged = new AnimationChanged(); animationChanged.setActor(player); plugin.onAnimationChanged(animationChanged); 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 when(player.getAnimation()).thenReturn(AnimationID.IDLE); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(new GameTick()); verify(notifier, times(0)).notify(any()); }
Example 6
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 7
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 8
Source File: EmojiPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 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 9
Source File: SlayerPluginTest.java From plugins with GNU General Public License v3.0 | 5 votes |
public void infoboxNotAddedOnLogin() { GameStateChanged loggingIn = new GameStateChanged(); loggingIn.setGameState(GameState.LOGGING_IN); slayerPlugin.onGameStateChanged(loggingIn); GameStateChanged loggedIn = new GameStateChanged(); loggedIn.setGameState(GameState.LOGGED_IN); slayerPlugin.onGameStateChanged(loggedIn); verify(infoBoxManager, never()).addInfoBox(any()); }
Example 10
Source File: XpTrackerPluginTest.java From plugins with GNU General Public License v3.0 | 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(GameTick.INSTANCE); // 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(GameTick.INSTANCE); // 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 11
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void infoboxNotAddedOnLogin() { when(slayerConfig.taskName()).thenReturn(Task.BLOODVELD.getName()); GameStateChanged loggingIn = new GameStateChanged(); loggingIn.setGameState(GameState.LOGGING_IN); slayerPlugin.onGameStateChanged(loggingIn); GameStateChanged loggedIn = new GameStateChanged(); loggedIn.setGameState(GameState.LOGGED_IN); slayerPlugin.onGameStateChanged(loggedIn); verify(infoBoxManager, never()).addInfoBox(any()); }
Example 12
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 13
Source File: MotherlodePluginTest.java From plugins with GNU General Public License v3.0 | 4 votes |
@Test public void testOreCounter() { // set inMlm GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOADING); motherlodePlugin.onGameStateChanged(gameStateChanged); // Initial sack count when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(42); motherlodePlugin.onVarbitChanged(new VarbitChanged()); // Create before inventory ItemContainer inventory = mock(ItemContainer.class); Item[] items = new Item[]{ item(ItemID.RUNITE_ORE, 1), item(ItemID.GOLDEN_NUGGET, 4), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), }; when(inventory.getItems()) .thenReturn(items); when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory); // Withdraw 20 when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(22); motherlodePlugin.onVarbitChanged(new VarbitChanged()); inventory = mock(ItemContainer.class); // +1 rune, +4 nugget, +2 coal, +1 addy items = new Item[]{ item(ItemID.RUNITE_ORE, 1), item(ItemID.RUNITE_ORE, 1), item(ItemID.GOLDEN_NUGGET, 8), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.ADAMANTITE_ORE, 1), }; when(inventory.getItems()) .thenReturn(items); when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory); // Trigger comparison motherlodePlugin.onItemContainerChanged(new ItemContainerChanged(InventoryID.INVENTORY.getId(), inventory)); verify(motherlodeSession).updateOreFound(ItemID.RUNITE_ORE, 1); verify(motherlodeSession).updateOreFound(ItemID.GOLDEN_NUGGET, 4); verify(motherlodeSession).updateOreFound(ItemID.COAL, 2); verify(motherlodeSession).updateOreFound(ItemID.ADAMANTITE_ORE, 1); verifyNoMoreInteractions(motherlodeSession); }
Example 14
Source File: MotherlodePluginTest.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Test public void testOreCounter() { // set inMlm GameStateChanged gameStateChanged = new GameStateChanged(); gameStateChanged.setGameState(GameState.LOADING); motherlodePlugin.onGameStateChanged(gameStateChanged); // Initial sack count when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(42); motherlodePlugin.onVarbitChanged(new VarbitChanged()); // Create before inventory ItemContainer inventory = mock(ItemContainer.class); Item[] items = new Item[]{ item(ItemID.RUNITE_ORE, 1), item(ItemID.GOLDEN_NUGGET, 4), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), }; when(inventory.getItems()) .thenReturn(items); when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory); // Withdraw 20 when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(22); motherlodePlugin.onVarbitChanged(new VarbitChanged()); inventory = mock(ItemContainer.class); // +1 rune, +4 nugget, +2 coal, +1 addy items = new Item[]{ item(ItemID.RUNITE_ORE, 1), item(ItemID.RUNITE_ORE, 1), item(ItemID.GOLDEN_NUGGET, 8), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.COAL, 1), item(ItemID.ADAMANTITE_ORE, 1), }; when(inventory.getItems()) .thenReturn(items); when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory); // Trigger comparison motherlodePlugin.onItemContainerChanged(new ItemContainerChanged(InventoryID.INVENTORY.getId(), inventory)); verify(motherlodeSession).updateOreFound(ItemID.RUNITE_ORE, 1); verify(motherlodeSession).updateOreFound(ItemID.GOLDEN_NUGGET, 4); verify(motherlodeSession).updateOreFound(ItemID.COAL, 2); verify(motherlodeSession).updateOreFound(ItemID.ADAMANTITE_ORE, 1); verifyNoMoreInteractions(motherlodeSession); }