MenuEntrySwapperPlugin extends Plugin { @Subscribe public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { if (shiftModifier() && config.bankDepositShiftClick() != ShiftDepositMode.OFF && menuEntryAdded.getType() == MenuAction.CC_OP.getId() && (menuEntryAdded.getIdentifier() == 2 || menuEntryAdded.getIdentifier() == 1) && menuEntryAdded.getOption().startsWith("Deposit-")) { ShiftDepositMode shiftDepositMode = config.bankDepositShiftClick(); final int opId = WidgetInfo.TO_GROUP(menuEntryAdded.getActionParam1()) == WidgetID.DEPOSIT_BOX_GROUP_ID ? shiftDepositMode.getIdentifierDepositBox() : shiftDepositMode.getIdentifier(); final int actionId = opId >= 6 ? MenuAction.CC_OP_LOW_PRIORITY.getId() : MenuAction.CC_OP.getId(); bankModeSwap(actionId, opId); } if (shiftModifier() && config.bankWithdrawShiftClick() != ShiftWithdrawMode.OFF && menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getIdentifier() == 1 && menuEntryAdded.getOption().startsWith("Withdraw-")) { ShiftWithdrawMode shiftWithdrawMode = config.bankWithdrawShiftClick(); final int actionId = shiftWithdrawMode.getMenuAction().getId(); final int opId = shiftWithdrawMode.getIdentifier(); bankModeSwap(actionId, opId); } }  @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);  }
@Test public void testShiftWithdraw() { when(config.bankDepositShiftClick()).thenReturn(ShiftDepositMode.EXTRA_OP); when(client.isKeyPressed(KeyCode.KC_SHIFT)).thenReturn(true); entries = new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Wield", "Abyssal whip", MenuAction.CC_OP_LOW_PRIORITY, 9), menu("Deposit-1", "Abyssal whip", MenuAction.CC_OP, 2), }; menuEntrySwapperPlugin.onMenuEntryAdded(new MenuEntryAdded( "Deposit-1", "Abyssal whip", MenuAction.CC_OP.getId(), 2, -1, -1 )); ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); verify(client).setMenuEntries(argumentCaptor.capture()); assertArrayEquals(new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Deposit-1", "Abyssal whip", MenuAction.CC_OP, 2), menu("Wield", "Abyssal whip", MenuAction.CC_OP, 9), }, argumentCaptor.getValue()); }
@Test public void testShiftDeposit() { when(config.bankDepositShiftClick()).thenReturn(ShiftDepositMode.DEPOSIT_ALL); when(client.isKeyPressed(KeyCode.KC_SHIFT)).thenReturn(true); entries = new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Wield", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 9), menu("Deposit-All", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 8), menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2), }; menuEntrySwapperPlugin.onMenuEntryAdded(new MenuEntryAdded( "Deposit-1", "Rune arrow", MenuAction.CC_OP.getId(), 2, -1, -1 )); ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); verify(client).setMenuEntries(argumentCaptor.capture()); assertArrayEquals(new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Wield", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 9), menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2), menu("Deposit-All", "Rune arrow", MenuAction.CC_OP, 8), }, argumentCaptor.getValue()); }