@Test public void testTeleport() { when(config.swapTeleportSpell()).thenReturn(true); when(client.isKeyPressed(KeyCode.KC_SHIFT)).thenReturn(true); entries = new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Configure", "Varrock Teleport", MenuAction.WIDGET_THIRD_OPTION), menu("Grand Exchange", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION), menu("Cast", "Varrock Teleport", MenuAction.WIDGET_FIRST_OPTION), }; menuEntrySwapperPlugin.onClientTick(new ClientTick()); ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); verify(client).setMenuEntries(argumentCaptor.capture()); assertArrayEquals(new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Configure", "Varrock Teleport", MenuAction.WIDGET_THIRD_OPTION), menu("Cast", "Varrock Teleport", MenuAction.WIDGET_FIRST_OPTION), menu("Grand Exchange", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION), }, argumentCaptor.getValue()); clearInvocations(client); entries = new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Configure", "Varrock Teleport", MenuAction.WIDGET_THIRD_OPTION), menu("Cast", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION), menu("Grand Exchange", "Varrock Teleport", MenuAction.WIDGET_FIRST_OPTION), }; menuEntrySwapperPlugin.onClientTick(new ClientTick()); argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); verify(client).setMenuEntries(argumentCaptor.capture()); assertArrayEquals(new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Configure", "Varrock Teleport", MenuAction.WIDGET_THIRD_OPTION), menu("Grand Exchange", "Varrock Teleport", MenuAction.WIDGET_FIRST_OPTION), menu("Cast", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION), }, argumentCaptor.getValue()); }
@Subscribe public void onClientTick(ClientTick clientTick) { if (client.getGameState() != GameState.LOGGED_IN || client.isMenuOpen()) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); int idx = 0; optionIndexes.clear(); for (MenuEntry entry : menuEntries) { String option = Text.removeTags(entry.getOption()).toLowerCase(); optionIndexes.put(option, idx++); } idx = 0; for (MenuEntry entry : menuEntries) { swapMenuEntry(idx++, entry); } }
MenuEntrySwapperPlugin extends Plugin { @Subscribe public void onClientTick(ClientTick clientTick) { if (client.getGameState() != GameState.LOGGED_IN || client.isMenuOpen()) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); int idx = 0; optionIndexes.clear(); for (MenuEntry entry : menuEntries) { String option = Text.removeTags(entry.getOption()).toLowerCase(); optionIndexes.put(option, idx++); } idx = 0; for (MenuEntry entry : menuEntries) { swapMenuEntry(idx++, entry); } } }
MenuEntrySwapperPlugin extends Plugin { @Subscribe public void onClientTick(ClientTick clientTick) { if (client.getGameState() != GameState.LOGGED_IN || client.isMenuOpen()) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); int idx = 0; optionIndexes.clear(); for (MenuEntry entry : menuEntries) { String option = Text.removeTags(entry.getOption()).toLowerCase(); optionIndexes.put(option, idx++); } idx = 0; for (MenuEntry entry : menuEntries) { swapMenuEntry(idx++, entry); } }  }
MenuEntrySwapperPlugin extends Plugin { @Subscribe public void onClientTick(ClientTick clientTick) { if (client.getGameState() != GameState.LOGGED_IN || client.isMenuOpen()) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); int idx = 0; optionIndexes.clear(); for (MenuEntry entry : menuEntries) { String option = Text.removeTags(entry.getOption()).toLowerCase(); optionIndexes.put(option, idx++); } idx = 0; for (MenuEntry entry : menuEntries) { swapMenuEntry(idx++, entry); } }  @Override void startUp(); @Override void shutDown(); @Subscribe void onConfigChanged(ConfigChanged event); @Subscribe void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event); @Subscribe void onMenuOpened(MenuOpened event); @Subscribe void onMenuEntryAdded(MenuEntryAdded menuEntryAdded); @Subscribe void onMenuOptionClicked(MenuOptionClicked event); @Subscribe void onClientTick(ClientTick clientTick); @Subscribe void onPostItemComposition(PostItemComposition event); }
MenuEntrySwapperPlugin extends Plugin { @Subscribe public void onClientTick(ClientTick clientTick) { if (client.getGameState() != GameState.LOGGED_IN || client.isMenuOpen()) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); int idx = 0; optionIndexes.clear(); for (MenuEntry entry : menuEntries) { String option = Text.removeTags(entry.getOption()).toLowerCase(); optionIndexes.put(option, idx++); } idx = 0; for (MenuEntry entry : menuEntries) { swapMenuEntry(idx++, entry); } }  @Override void startUp(); @Override void shutDown(); @Subscribe void onConfigChanged(ConfigChanged event); @Subscribe void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event); @Subscribe void onMenuOpened(MenuOpened event); @Subscribe void onMenuEntryAdded(MenuEntryAdded menuEntryAdded); @Subscribe void onMenuOptionClicked(MenuOptionClicked event); @Subscribe void onClientTick(ClientTick clientTick); @Subscribe void onPostItemComposition(PostItemComposition event);  }