net.runelite.api.events.MenuEntryAdded Java Examples
The following examples show how to use
net.runelite.api.events.MenuEntryAdded.
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: NpcIndicatorsPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testDeadNpcMenuHighlight() { when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin"); when(npcIndicatorsConfig.deadNpcMenuColor()).thenReturn(Color.RED); ConfigChanged configChanged = new ConfigChanged(); configChanged.setGroup("npcindicators"); npcIndicatorsPlugin.onConfigChanged(configChanged); NPC npc = mock(NPC.class); when(npc.getName()).thenReturn("Goblin"); when(npc.isDead()).thenReturn(true); npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc)); when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0 when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()}); MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuOpcode.NPC_FIRST_OPTION.getId(), 0, -1, -1, false); npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded); MenuEntry target = new MenuEntry(); target.setTarget("<col=ff0000>Goblin"); // red verify(client).setMenuEntries(new MenuEntry[]{target}); }
Example #2
Source File: CameraPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { if (menuEntryAdded.getOpcode() == MenuOpcode.CC_OP.getId() && menuEntryAdded.getOption().equals(LOOK_NORTH) && config.compassLook()) { MenuEntry[] menuEntries = client.getMenuEntries(); int len = menuEntries.length; MenuEntry north = menuEntries[len - 1]; menuEntries = Arrays.copyOf(menuEntries, len + 3); // The handling for these entries is done in ToplevelCompassOp.rs2asm menuEntries[--len] = createCameraLookEntry(menuEntryAdded, 4, LOOK_WEST); menuEntries[++len] = createCameraLookEntry(menuEntryAdded, 3, LOOK_EAST); menuEntries[++len] = createCameraLookEntry(menuEntryAdded, 2, LOOK_SOUTH); menuEntries[++len] = north; client.setMenuEntries(menuEntries); } }
Example #3
Source File: CorpPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if (event.getOpcode() != NPC_SECOND_OPTION.getId() || !config.leftClickCore() || !event.getOption().equals(ATTACK)) { return; } final int npcIndex = event.getIdentifier(); final NPC npc = client.getCachedNPCs()[npcIndex]; if (npc == null || !npc.getName().equals(DARK_ENERGY_CORE)) { return; } event.setOpcode(NPC_SECOND_OPTION.getId() + MENU_ACTION_DEPRIORITIZE_OFFSET); event.setModified(); }
Example #4
Source File: NpcIndicatorsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testAliveNpcMenuHighlight() { when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin"); when(npcIndicatorsConfig.highlightMenuNames()).thenReturn(true); when(npcIndicatorsConfig.getHighlightColor()).thenReturn(Color.BLUE); ConfigChanged configChanged = new ConfigChanged(); configChanged.setGroup("npcindicators"); npcIndicatorsPlugin.onConfigChanged(configChanged); NPC npc = mock(NPC.class); when(npc.getName()).thenReturn("Goblin"); npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc)); when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0 when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()}); MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1); npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded); MenuEntry target = new MenuEntry(); target.setTarget("<col=0000ff>Goblin"); // blue verify(client).setMenuEntries(new MenuEntry[]{target}); }
Example #5
Source File: NpcIndicatorsPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testDeadNpcMenuHighlight() { when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin"); when(npcIndicatorsConfig.deadNpcMenuColor()).thenReturn(Color.RED); ConfigChanged configChanged = new ConfigChanged(); configChanged.setGroup("npcindicators"); npcIndicatorsPlugin.onConfigChanged(configChanged); NPC npc = mock(NPC.class); when(npc.getName()).thenReturn("Goblin"); when(npc.isDead()).thenReturn(true); npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc)); when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0 when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()}); MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1); npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded); MenuEntry target = new MenuEntry(); target.setTarget("<col=ff0000>Goblin"); // red verify(client).setMenuEntries(new MenuEntry[]{target}); }
Example #6
Source File: NpcIndicatorsPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testAliveNpcMenuHighlight() { when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin"); when(npcIndicatorsConfig.highlightMenuNames()).thenReturn(true); when(npcIndicatorsConfig.getHighlightColor()).thenReturn(Color.BLUE); ConfigChanged configChanged = new ConfigChanged(); configChanged.setGroup("npcindicators"); npcIndicatorsPlugin.onConfigChanged(configChanged); NPC npc = mock(NPC.class); when(npc.getName()).thenReturn("Goblin"); npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc)); when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0 when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()}); MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuOpcode.NPC_FIRST_OPTION.getId(), 0, -1, -1, false); npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded); MenuEntry target = new MenuEntry(); target.setTarget("<col=0000ff>Goblin"); // blue verify(client).setMenuEntries(new MenuEntry[]{target}); }
Example #7
Source File: FriendTaggingPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { final int groupId = WidgetInfo.TO_GROUP(event.getParam1()); if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() && event.getOption().equals("Message")) { // Friends have color tags String friendName = Text.removeTags(event.getTarget()); // Build "Add Note" or "Edit Note" menu entry client.insertMenuItem( friendName == null || getTag(friendName) == null ? ADD_TAG : DELETE_TAG, event.getTarget(), MenuOpcode.RUNELITE.getId(), 0, event.getParam0(), event.getParam1(), false ); // Add menu entry // jk it is already added } }
Example #8
Source File: CameraPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { if (menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getOption().equals(LOOK_NORTH) && config.compassLook()) { MenuEntry[] menuEntries = client.getMenuEntries(); int len = menuEntries.length; MenuEntry north = menuEntries[len - 1]; menuEntries = Arrays.copyOf(menuEntries, len + 3); // The handling for these entries is done in ToplevelCompassOp.rs2asm menuEntries[--len] = createCameraLookEntry(menuEntryAdded, 4, LOOK_WEST); menuEntries[++len] = createCameraLookEntry(menuEntryAdded, 3, LOOK_EAST); menuEntries[++len] = createCameraLookEntry(menuEntryAdded, 2, LOOK_SOUTH); menuEntries[++len] = north; client.setMenuEntries(menuEntries); } }
Example #9
Source File: LearnToClickPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if ((event.getOption().equals("Floating <col=ff9040>World Map</col>") && config.shouldRightClickMap()) || (event.getTarget().equals("<col=ff9040>XP drops</col>") && config.shouldRightClickXp()) || (event.getOption().equals("Auto retaliate") && config.shouldRightClickRetaliate())) { forceRightClickFlag = true; } MenuEntry[] entries = client.getMenuEntries(); if (config.shouldBlockCompass()) { for (int i = entries.length - 1; i >= 0; i--) { if (entries[i].getOption().equals("Look North")) { entries = ArrayUtils.remove(entries, i); i--; } } client.setMenuEntries(entries); } }
Example #10
Source File: OpponentInfoPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { if (menuEntryAdded.getType() != MenuAction.NPC_SECOND_OPTION.getId() || !menuEntryAdded.getOption().equals("Attack") || !config.showOpponentsInMenu()) { return; } int npcIndex = menuEntryAdded.getIdentifier(); NPC npc = client.getCachedNPCs()[npcIndex]; if (npc == null) { return; } if (npc.getInteracting() == client.getLocalPlayer() || lastOpponent == npc) { MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries[menuEntries.length - 1].setTarget("*" + menuEntryAdded.getTarget()); client.setMenuEntries(menuEntries); } }
Example #11
Source File: CameraPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private MenuEntry createCameraLookEntry(MenuEntryAdded lookNorth, int identifier, String option) { MenuEntry m = new MenuEntry(); m.setOption(option); m.setTarget(lookNorth.getTarget()); m.setIdentifier(identifier); m.setType(MenuAction.CC_OP.getId()); m.setParam0(lookNorth.getActionParam0()); m.setParam1(lookNorth.getActionParam1()); return m; }
Example #12
Source File: GrandExchangePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { // At the moment, if the user disables quick lookup, the input listener gets disabled. Thus, isHotKeyPressed() // should always return false when quick lookup is disabled. // Replace the default option with "Search ..." when holding alt if (client.getGameState() != GameState.LOGGED_IN || !hotKeyPressed) { return; } final MenuEntry[] entries = client.getMenuEntries(); final MenuEntry menuEntry = entries[entries.length - 1]; final int widgetId = menuEntry.getParam1(); final int groupId = WidgetInfo.TO_GROUP(widgetId); switch (groupId) { case WidgetID.BANK_GROUP_ID: // Don't show for view tabs and such if (WidgetInfo.TO_CHILD(widgetId) != WidgetInfo.BANK_ITEM_CONTAINER.getChildId()) { break; } case WidgetID.INVENTORY_GROUP_ID: case WidgetID.BANK_INVENTORY_GROUP_ID: case WidgetID.GRAND_EXCHANGE_INVENTORY_GROUP_ID: case WidgetID.SHOP_INVENTORY_GROUP_ID: menuEntry.setOption(SEARCH_GRAND_EXCHANGE); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(entries); } }
Example #13
Source File: BankPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if ((event.getOption().equals(DEPOSIT_WORN) && config.rightClickBankEquip()) || (event.getOption().equals(DEPOSIT_INVENTORY) && config.rightClickBankInventory()) || (event.getOption().equals(DEPOSIT_LOOT) && config.rightClickBankLoot())) { forceRightClickFlag = true; } }
Example #14
Source File: GroundMarkerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { final boolean hotKeyPressed = client.isKeyPressed(KeyCode.KC_SHIFT); if (hotKeyPressed && event.getOption().equals(WALK_HERE)) { final Tile selectedSceneTile = client.getSelectedSceneTile(); if (selectedSceneTile == null) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, selectedSceneTile.getLocalLocation()); final int regionId = worldPoint.getRegionID(); final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), config.markerColor()); menuEntry.setOption(getPoints(regionId).contains(point) ? UNMARK : MARK); menuEntry.setTarget(event.getTarget()); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(menuEntries); } }
Example #15
Source File: MenuManager.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (client.getSpellSelected()) { return; } int widgetId = event.getActionParam1(); Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId); for (WidgetMenuOption currentMenu : options) { if (!menuContainsCustomMenu(currentMenu))//Don't add if we have already added it to this widget { MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); menuEntry.setOption(currentMenu.getMenuOption()); menuEntry.setParam1(widgetId); menuEntry.setTarget(currentMenu.getMenuTarget()); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(menuEntries); } } }
Example #16
Source File: DevToolsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (!examine.isActive()) { return; } MenuAction action = MenuAction.of(event.getType()); if (EXAMINE_MENU_ACTIONS.contains(action)) { MenuEntry[] entries = client.getMenuEntries(); MenuEntry entry = entries[entries.length - 1]; final int identifier = event.getIdentifier(); String info = "ID: "; if (action == MenuAction.EXAMINE_NPC) { NPC npc = client.getCachedNPCs()[identifier]; info += npc.getId(); } else { info += identifier; if (action == MenuAction.EXAMINE_OBJECT) { WorldPoint point = WorldPoint.fromScene(client, entry.getParam0(), entry.getParam1(), client.getPlane()); info += " X: " + point.getX() + " Y: " + point.getY(); } } entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET)); client.setMenuEntries(entries); } }
Example #17
Source File: WidgetInspector.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if (!pickerSelected) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); for (int i = 0; i < menuEntries.length; i++) { MenuEntry entry = menuEntries[i]; if (entry.getType() != MenuAction.ITEM_USE_ON_WIDGET.getId() && entry.getType() != MenuAction.SPELL_CAST_ON_WIDGET.getId()) { continue; } String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1()); if (entry.getParam0() != -1) { name += " [" + entry.getParam0() + "]"; } Color color = colorForWidget(i, menuEntries.length); entry.setTarget(ColorUtil.wrapWithColorTag(name, color)); } client.setMenuEntries(menuEntries); }
Example #18
Source File: DevToolsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded entry) { if (!examine.isActive()) { return; } MenuOpcode action = MenuOpcode.of(entry.getOpcode()); if (EXAMINE_MENU_ACTIONS.contains(action)) { final int identifier = entry.getIdentifier(); String info = "ID: "; if (action == MenuOpcode.EXAMINE_NPC) { NPC npc = client.getCachedNPCs()[identifier]; info += npc.getId(); } else { info += identifier; if (action == MenuOpcode.EXAMINE_OBJECT) { WorldPoint point = WorldPoint.fromScene(client, entry.getParam0(), entry.getParam1(), client.getPlane()); info += " X: " + point.getX() + " Y: " + point.getY(); } } entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET)); entry.setModified(); } }
Example #19
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private static MenuEntry[] createMenuEntry(MenuEntryAdded event, String option, String target, MenuEntry[] entries) { final MenuEntry entry = new MenuEntry(); entry.setParam0(event.getActionParam0()); entry.setParam1(event.getActionParam1()); entry.setTarget(target); entry.setOption(option); entry.setType(MenuAction.RUNELITE.getId()); entry.setIdentifier(event.getIdentifier()); entries = Arrays.copyOf(entries, entries.length + 1); entries[entries.length - 1] = entry; return entries; }
Example #20
Source File: BankTagsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { MenuEntry[] entries = client.getMenuEntries(); if (event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getOption().equals("Examine")) { Widget container = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); Widget item = container.getChild(event.getActionParam0()); int itemID = item.getItemId(); String text = EDIT_TAGS_MENU_OPTION; int tagCount = tagManager.getTags(itemID, false).size() + tagManager.getTags(itemID, true).size(); if (tagCount > 0) { text += " (" + tagCount + ")"; } MenuEntry editTags = new MenuEntry(); editTags.setParam0(event.getActionParam0()); editTags.setParam1(event.getActionParam1()); editTags.setTarget(event.getTarget()); editTags.setOption(text); editTags.setType(MenuAction.RUNELITE.getId()); editTags.setIdentifier(event.getIdentifier()); entries = Arrays.copyOf(entries, entries.length + 1); entries[entries.length - 1] = editTags; client.setMenuEntries(entries); } tabInterface.handleAdd(event); }
Example #21
Source File: ObjectIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (event.getType() != MenuAction.EXAMINE_OBJECT.getId() || !client.isKeyPressed(KeyCode.KC_SHIFT)) { return; } final Tile tile = client.getScene().getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()]; final TileObject tileObject = findTileObject(tile, event.getIdentifier()); if (tileObject == null) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); menuEntry.setOption(objects.stream().anyMatch(o -> o.getTileObject() == tileObject) ? UNMARK : MARK); menuEntry.setTarget(event.getTarget()); menuEntry.setParam0(event.getActionParam0()); menuEntry.setParam1(event.getActionParam1()); menuEntry.setIdentifier(event.getIdentifier()); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(menuEntries); }
Example #22
Source File: FriendNotesPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { final int groupId = WidgetInfo.TO_GROUP(event.getActionParam1()); // Look for "Message" on friends list if ((groupId == WidgetInfo.FRIENDS_LIST.getGroupId() && event.getOption().equals("Message")) || (groupId == WidgetInfo.IGNORE_LIST.getGroupId() && event.getOption().equals("Delete"))) { // Friends have color tags setHoveredFriend(Text.toJagexName(Text.removeTags(event.getTarget()))); // Build "Add Note" or "Edit Note" menu entry final MenuEntry addNote = new MenuEntry(); addNote.setOption(hoveredFriend == null || hoveredFriend.getNote() == null ? ADD_NOTE : EDIT_NOTE); addNote.setType(MenuAction.RUNELITE.getId()); addNote.setTarget(event.getTarget()); //Preserve color codes here addNote.setParam0(event.getActionParam0()); addNote.setParam1(event.getActionParam1()); // Add menu entry final MenuEntry[] menuEntries = ObjectArrays.concat(client.getMenuEntries(), addNote); client.setMenuEntries(menuEntries); } else if (hoveredFriend != null) { hoveredFriend = null; } }
Example #23
Source File: RandomEventPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (event.getType() >= MenuAction.NPC_FIRST_OPTION.getId() && event.getType() <= MenuAction.NPC_FIFTH_OPTION.getId() && EVENT_OPTIONS.contains(event.getOption())) { NPC npc = client.getCachedNPCs()[event.getIdentifier()]; if (npc != null && EVENT_NPCS.contains(npc.getId()) && npc != currentRandomEvent && config.removeMenuOptions()) { client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), client.getMenuEntries().length - 1)); } } }
Example #24
Source File: XpTrackerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(final MenuEntryAdded event) { int widgetID = event.getActionParam1(); if (TO_GROUP(widgetID) != WidgetID.SKILLS_GROUP_ID || !event.getOption().startsWith("View") || !xpTrackerConfig.skillTabOverlayMenuOptions()) { return; } // Get skill from menu option, eg. "View <col=ff981f>Attack</col> guide" final String skillText = event.getOption().split(" ")[1]; final Skill skill = Skill.valueOf(Text.removeTags(skillText).toUpperCase()); MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); menuEntry.setTarget(skillText); menuEntry.setOption(hasOverlay(skill) ? MENUOP_REMOVE_CANVAS_TRACKER : MENUOP_ADD_CANVAS_TRACKER); menuEntry.setParam0(event.getActionParam0()); menuEntry.setParam1(widgetID); menuEntry.setType(MenuAction.RUNELITE.getId()); client.setMenuEntries(menuEntries); }
Example #25
Source File: HiscorePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (!config.menuOption()) { return; } int groupId = WidgetInfo.TO_GROUP(event.getActionParam1()); String option = event.getOption(); if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId() || groupId == WidgetInfo.CHATBOX.getGroupId() && !KICK_OPTION.equals(option) || //prevent from adding for Kick option (interferes with the raiding party one) groupId == WidgetInfo.RAIDING_PARTY.getGroupId() || groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId() || groupId == WidgetInfo.IGNORE_LIST.getGroupId()) { if (!AFTER_OPTIONS.contains(option) || (option.equals("Delete") && groupId != WidgetInfo.IGNORE_LIST.getGroupId())) { return; } final MenuEntry lookup = new MenuEntry(); lookup.setOption(LOOKUP); lookup.setTarget(event.getTarget()); lookup.setType(MenuAction.RUNELITE.getId()); lookup.setParam0(event.getActionParam0()); lookup.setParam1(event.getActionParam1()); lookup.setIdentifier(event.getIdentifier()); insertMenuEntry(lookup, client.getMenuEntries()); } }
Example #26
Source File: ChatHistoryPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded entry) { final ChatboxTab tab = ChatboxTab.of(entry.getActionParam1()); if (tab == null || !config.clearHistory() || !Text.removeTags(entry.getOption()).equals(tab.getAfter())) { return; } final MenuEntry clearEntry = new MenuEntry(); clearEntry.setTarget(""); clearEntry.setType(MenuAction.RUNELITE.getId()); clearEntry.setParam0(entry.getActionParam0()); clearEntry.setParam1(entry.getActionParam1()); if (tab == ChatboxTab.GAME) { // keep type as the original CC_OP to correctly group "Game: Clear history" with // other tab "Game: *" options. clearEntry.setType(entry.getType()); } final StringBuilder messageBuilder = new StringBuilder(); if (tab != ChatboxTab.ALL) { messageBuilder.append(ColorUtil.wrapWithColorTag(tab.getName() + ": ", Color.YELLOW)); } messageBuilder.append(CLEAR_HISTORY); clearEntry.setOption(messageBuilder.toString()); final MenuEntry[] menuEntries = client.getMenuEntries(); client.setMenuEntries(ArrayUtils.insert(menuEntries.length - 1, menuEntries, clearEntry)); }
Example #27
Source File: MenuEntrySwapperPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@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()); }
Example #28
Source File: MenuEntrySwapperPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@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()); }
Example #29
Source File: SlayermusiqPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { int widgetID = event.getParam1(); if (Ints.contains(QUESTLIST_WIDGET_IDS, widgetID) && "Read Journal:".equals(event.getOption())) { MenuEntry[] menuEntries = client.getMenuEntries(); MenuEntry newMenuEntry = createSlayermusiqOptionMenuEntry(event); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); menuEntries[menuEntries.length - 1] = newMenuEntry; client.setMenuEntries(menuEntries); } }
Example #30
Source File: WidgetInspector.java From plugins with GNU General Public License v3.0 | 5 votes |
private void onMenuEntryAdded(MenuEntryAdded event) { if (!pickerSelected) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); for (int i = 0; i < menuEntries.length; i++) { MenuEntry entry = menuEntries[i]; if (entry.getOpcode() != MenuOpcode.ITEM_USE_ON_WIDGET.getId() && entry.getOpcode() != MenuOpcode.SPELL_CAST_ON_WIDGET.getId()) { continue; } String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1()); if (entry.getParam0() != -1) { name += " [" + entry.getParam0() + "]"; } Color color = colorForWidget(i, menuEntries.length); entry.setTarget(ColorUtil.wrapWithColorTag(name, color)); } client.setMenuEntries(menuEntries); }