net.runelite.api.events.MenuOptionClicked Java Examples
The following examples show how to use
net.runelite.api.events.MenuOptionClicked.
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: ExaminePluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testLargeStacks() { when(client.getWidget(anyInt(), anyInt())).thenReturn(mock(Widget.class)); when(itemManager.getItemComposition(anyInt())).thenReturn(mock(ItemComposition.class)); MenuOptionClicked menuOptionClicked = new MenuOptionClicked(); menuOptionClicked.setMenuOption("Examine"); menuOptionClicked.setMenuAction(MenuAction.EXAMINE_ITEM); menuOptionClicked.setId(ItemID.ABYSSAL_WHIP); examinePlugin.onMenuOptionClicked(menuOptionClicked); ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.ITEM_EXAMINE, "", "100000 x Abyssal whip", "", 0); examinePlugin.onChatMessage(chatMessage); verify(examineClient, never()).submitItem(anyInt(), anyString()); }
Example #2
Source File: ChatHistoryPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { final String menuOption = event.getOption(); // The menu option for clear history is "<col=ffff00>Public:</col> Clear history" if (menuOption.endsWith(CLEAR_HISTORY)) { clearChatboxHistory(ChatboxTab.of(event.getParam1())); } else if (COPY_TO_CLIPBOARD.equals(menuOption) && !Strings.isNullOrEmpty(currentMessage)) { final StringSelection stringSelection = new StringSelection(Text.removeTags(currentMessage)); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null); } }
Example #3
Source File: InfoBoxOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) { if (menuOptionClicked.getMenuAction() != MenuAction.RUNELITE_INFOBOX) { return; } InfoBox infoBox = hoveredComponent.getInfoBox(); OverlayMenuEntry overlayMenuEntry = infoBox.getMenuEntries().stream() .filter(me -> me.getOption().equals(menuOptionClicked.getMenuOption())) .findAny() .orElse(null); if (overlayMenuEntry != null) { eventBus.post(new InfoBoxMenuClicked(overlayMenuEntry, infoBox)); } }
Example #4
Source File: MotherlodePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked menu) { if (!inMlm) { return; } if (MINE_SPOTS.contains(menu.getIdentifier()) && menu.getMenuOpcode() == MenuOpcode.GAME_OBJECT_FIRST_OPTION) { resetIdleChecks(); int veinX = menu.getParam0(); int veinY = menu.getParam1(); targetVeinLocation = WorldPoint.fromScene(client, veinX, veinY, client.getPlane()); } }
Example #5
Source File: ChatTranslationPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void onMenuOptionClicked(MenuOptionClicked event) { if (event.getOpcode() != MenuOpcode.RUNELITE.getId() || !event.getOption().equals(TRANSLATE)) { return; } String name = Text.toJagexName( Text.removeTags(event.getTarget(), true) .toLowerCase() ); playerNames.add(name); config.playerNames(Text.toCSV(playerNames)); }
Example #6
Source File: OverlayManager.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { MenuAction menuAction = event.getMenuAction(); if (menuAction != MenuAction.RUNELITE_OVERLAY && menuAction != MenuAction.RUNELITE_OVERLAY_CONFIG) { return; } event.consume(); Overlay overlay = overlays.get(event.getId()); if (overlay != null) { List<OverlayMenuEntry> menuEntries = overlay.getMenuEntries(); OverlayMenuEntry overlayMenuEntry = menuEntries.stream() .filter(me -> me.getOption().equals(event.getMenuOption())) .findAny() .orElse(null); if (overlayMenuEntry != null) { eventBus.post(new OverlayMenuClicked(overlayMenuEntry, overlay)); } } }
Example #7
Source File: InventoryTagsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuOptionClicked(final MenuOptionClicked event) { if (event.getMenuAction() != MenuAction.RUNELITE) { return; } final String selectedMenu = Text.removeTags(event.getMenuTarget()); if (event.getMenuOption().equals(MENU_SET)) { setTag(event.getId(), selectedMenu); } else if (event.getMenuOption().equals(MENU_REMOVE)) { unsetTag(event.getId()); } }
Example #8
Source File: HerbiboarPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked menuOpt) { if (!inHerbiboarArea || started || MenuAction.GAME_OBJECT_FIRST_OPTION != menuOpt.getMenuAction()) { return; } switch (Text.removeTags(menuOpt.getMenuTarget())) { case "Rock": case "Mushroom": case "Driftwood": startPoint = WorldPoint.fromScene(client, menuOpt.getActionParam(), menuOpt.getWidgetId(), client.getPlane()); } }
Example #9
Source File: GroundMarkerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { if (event.getMenuAction().getId() != MenuAction.RUNELITE.getId() || !(event.getMenuOption().equals(MARK) || event.getMenuOption().equals(UNMARK))) { return; } Tile target = client.getSelectedSceneTile(); if (target == null) { return; } markTile(target.getLocalLocation()); }
Example #10
Source File: HerbiboarPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked menuOpt) { if (!inHerbiboarArea || started || MenuOpcode.GAME_OBJECT_FIRST_OPTION != menuOpt.getMenuOpcode()) { return; } switch (Text.removeTags(menuOpt.getTarget())) { case "Rock": case "Mushroom": case "Driftwood": startPoint = WorldPoint.fromScene(client, menuOpt.getParam0(), menuOpt.getParam1(), client.getPlane()); } }
Example #11
Source File: ChatHistoryPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { final String menuOption = event.getMenuOption(); // The menu option for clear history is "<col=ffff00>Public:</col> Clear history" if (menuOption.endsWith(CLEAR_HISTORY)) { clearChatboxHistory(ChatboxTab.of(event.getWidgetId())); } else if (COPY_TO_CLIPBOARD.equals(menuOption) && !Strings.isNullOrEmpty(currentMessage)) { final StringSelection stringSelection = new StringSelection(Text.removeTags(currentMessage)); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null); } }
Example #12
Source File: ExaminePluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testItem() { when(client.getWidget(anyInt(), anyInt())).thenReturn(mock(Widget.class)); when(itemManager.getItemComposition(anyInt())).thenReturn(mock(ItemComposition.class)); MenuOptionClicked menuOptionClicked = new MenuOptionClicked(); menuOptionClicked.setMenuOption("Examine"); menuOptionClicked.setMenuAction(MenuAction.EXAMINE_ITEM); menuOptionClicked.setId(ItemID.ABYSSAL_WHIP); examinePlugin.onMenuOptionClicked(menuOptionClicked); ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.ITEM_EXAMINE, "", "A weapon from the abyss.", "", 0); examinePlugin.onChatMessage(chatMessage); // This passes due to not mocking the ItemComposition for the whip verify(examineClient).submitItem(anyInt(), anyString()); }
Example #13
Source File: WidgetInspector.java From plugins with GNU General Public License v3.0 | 6 votes |
private void onMenuOptionClicked(MenuOptionClicked ev) { if (!pickerSelected) { return; } onPickerDeselect(); client.setSpellSelected(false); ev.consume(); Object target = getWidgetOrWidgetItemForMenuOption(ev.getMenuOpcode().getId(), ev.getParam0(), ev.getParam1()); if (target == null) { return; } if (target instanceof WidgetItem) { WidgetItem iw = (WidgetItem) target; setSelectedWidget(iw.getWidget(), iw.getIndex(), true); } else { setSelectedWidget((Widget) target, -1, true); } }
Example #14
Source File: InventoryTagsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuOptionClicked(final MenuOptionClicked event) { if (event.getMenuOpcode() != MenuOpcode.RUNELITE) { return; } final String selectedMenu = Text.removeTags(event.getTarget()); if (event.getOption().equals(MENU_SET)) { setTag(event.getIdentifier(), selectedMenu); } else if (event.getOption().equals(MENU_REMOVE)) { unsetTag(event.getIdentifier()); } }
Example #15
Source File: ExaminePluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testLargeStacks() { when(client.getWidget(anyInt(), anyInt())).thenReturn(mock(Widget.class)); when(itemManager.getItemDefinition(anyInt())).thenReturn(mock(ItemDefinition.class)); MenuOptionClicked menuOptionClicked = new MenuOptionClicked( "Examine", "Something", ItemID.ABYSSAL_WHIP, MenuOpcode.EXAMINE_ITEM.getId(), 123, 456, false ); examinePlugin.onMenuOptionClicked(menuOptionClicked); ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.ITEM_EXAMINE, "", "100000 x Abyssal whip", "", 0); examinePlugin.onChatMessage(chatMessage); verify(examineClient, never()).submitItem(anyInt(), anyString()); }
Example #16
Source File: ExaminePluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testItem() { when(client.getWidget(anyInt(), anyInt())).thenReturn(mock(Widget.class)); when(itemManager.getItemDefinition(anyInt())).thenReturn(mock(ItemDefinition.class)); MenuOptionClicked menuOptionClicked = new MenuOptionClicked( "Examine", "Something", ItemID.ABYSSAL_WHIP, MenuOpcode.EXAMINE_ITEM.getId(), 123, 456, false ); examinePlugin.onMenuOptionClicked(menuOptionClicked); ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.ITEM_EXAMINE, "", "A weapon from the abyss.", "", 0); examinePlugin.onChatMessage(chatMessage); // This passes due to not mocking the ItemDefinition for the whip verify(examineClient).submitItem(anyInt(), anyString()); }
Example #17
Source File: GroundMarkerPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { if (!event.getOption().contains(MARK) && !event.getOption().contains(UNMARK)) { return; } int group = 1; Matcher m = GROUP_MATCHER.matcher(event.getOption()); if (m.matches()) { group = Integer.parseInt(m.group(1)); } Tile target = client.getSelectedSceneTile(); if (target == null) { return; } markTile(target.getLocalLocation(), group); }
Example #18
Source File: WikiPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void checkQuestClicked(MenuOptionClicked ev) { boolean quickguide = false; switch (ev.getOption()) { case MENUOP_QUICKGUIDE: quickguide = true; //fallthrough; case MENUOP_GUIDE: ev.consume(); String quest = Text.removeTags(ev.getTarget()); HttpUrl.Builder ub = WIKI_BASE.newBuilder() .addPathSegment("w") .addPathSegment(quest) .addQueryParameter(UTM_SOURCE_KEY, UTM_SOURCE_VALUE); if (quickguide) { ub.addPathSegment("Quick_guide"); } LinkBrowser.browse(ub.build().toString()); break; case MENUOP_WIKI: LinkBrowser.browse(WIKI_BASE.newBuilder() .addPathSegment("w") .addPathSegment(Text.removeTags(ev.getTarget())) .addQueryParameter(UTM_SOURCE_KEY, UTM_SOURCE_VALUE) .build().toString()); } }
Example #19
Source File: MenuManagerTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testPlayerMenuOptionWithBountyHunterEmblemClicked() { MenuOptionClicked event = new MenuOptionClicked(); event.setMenuAction(MenuAction.RUNELITE_PLAYER); event.setMenuTarget("username<img=20>5<col=40ff00> (level-42)"); menuManager.onMenuOptionClicked(event); ArgumentCaptor<PlayerMenuOptionClicked> captor = ArgumentCaptor.forClass(PlayerMenuOptionClicked.class); verify(eventBus).post(captor.capture()); PlayerMenuOptionClicked clicked = captor.getValue(); assertEquals("username", clicked.getMenuTarget()); }
Example #20
Source File: MenuManager.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { if (event.getMenuAction() != MenuAction.RUNELITE && event.getMenuAction() != MenuAction.RUNELITE_PLAYER) { return; // not a managed widget option or custom player option } int widgetId = event.getWidgetId(); Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId); for (WidgetMenuOption curMenuOption : options) { if (curMenuOption.getMenuTarget().equals(event.getMenuTarget()) && curMenuOption.getMenuOption().equals(event.getMenuOption())) { WidgetMenuOptionClicked customMenu = new WidgetMenuOptionClicked(); customMenu.setMenuOption(event.getMenuOption()); customMenu.setMenuTarget(event.getMenuTarget()); customMenu.setWidget(curMenuOption.getWidget()); eventBus.post(customMenu); return; // don't continue because it's not a player option } } // removes bounty hunter emblem tag and tier from player name, e.g: // "username<img=20>5<col=40ff00> (level-42)" -> "username<col=40ff00> (level-42)" String target = BOUNTY_EMBLEM_TAG_AND_TIER_REGEXP.matcher(event.getMenuTarget()).replaceAll(""); // removes tags and level from player names for example: // <col=ffffff>username<col=40ff00> (level-42) or <col=ffffff><img=2>username</col> String username = Text.removeTags(target).split("[(]")[0].trim(); PlayerMenuOptionClicked playerMenuOptionClicked = new PlayerMenuOptionClicked(); playerMenuOptionClicked.setMenuOption(event.getMenuOption()); playerMenuOptionClicked.setMenuTarget(username); eventBus.post(playerMenuOptionClicked); }
Example #21
Source File: KourendLibraryPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked menuOpt) { if (MenuAction.GAME_OBJECT_FIRST_OPTION == menuOpt.getMenuAction() && menuOpt.getMenuTarget().contains("Bookshelf")) { lastBookcaseClick = WorldPoint.fromScene(client, menuOpt.getActionParam(), menuOpt.getWidgetId(), client.getPlane()); } }
Example #22
Source File: WidgetInspector.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked ev) { if (!pickerSelected) { return; } onPickerDeselect(); client.setSpellSelected(false); ev.consume(); Object target = getWidgetOrWidgetItemForMenuOption(ev.getMenuAction().getId(), ev.getActionParam(), ev.getWidgetId()); if (target == null) { return; } if (target instanceof WidgetItem) { WidgetItem iw = (WidgetItem) target; setSelectedWidget(iw.getWidget(), iw.getIndex(), true); } else { setSelectedWidget((Widget) target, -1, true); } }
Example #23
Source File: MenuManagerTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testPlayerMenuOptionClicked() { MenuOptionClicked event = new MenuOptionClicked(); event.setMenuAction(MenuAction.RUNELITE_PLAYER); event.setMenuTarget("username<col=40ff00> (level-42)"); menuManager.onMenuOptionClicked(event); ArgumentCaptor<PlayerMenuOptionClicked> captor = ArgumentCaptor.forClass(PlayerMenuOptionClicked.class); verify(eventBus).post(captor.capture()); PlayerMenuOptionClicked clicked = captor.getValue(); assertEquals("username", clicked.getMenuTarget()); }
Example #24
Source File: PartyPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { if (!client.isKeyPressed(KeyCode.KC_SHIFT) || client.isMenuOpen() || party.getMembers().isEmpty() || !config.pings()) { return; } Tile selectedSceneTile = client.getSelectedSceneTile(); if (selectedSceneTile == null) { return; } boolean isOnCanvas = false; for (MenuEntry menuEntry : client.getMenuEntries()) { if (menuEntry == null) { continue; } if ("walk here".equalsIgnoreCase(menuEntry.getOption())) { isOnCanvas = true; } } if (!isOnCanvas) { return; } event.consume(); final TilePing tilePing = new TilePing(selectedSceneTile.getWorldLocation()); tilePing.setMemberId(party.getLocalMember().getMemberId()); wsClient.send(tilePing); }
Example #25
Source File: ObjectIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { if (event.getMenuAction() != MenuAction.RUNELITE || !(event.getMenuOption().equals(MARK) || event.getMenuOption().equals(UNMARK))) { return; } Scene scene = client.getScene(); Tile[][][] tiles = scene.getTiles(); final int x = event.getActionParam(); final int y = event.getWidgetId(); final int z = client.getPlane(); final Tile tile = tiles[z][x][y]; TileObject object = findTileObject(tile, event.getId()); if (object == null) { return; } // object.getId() is always the base object id, getObjectComposition transforms it to // the correct object we see ObjectComposition objectDefinition = getObjectComposition(object.getId()); String name = objectDefinition.getName(); // Name is probably never "null" - however prevent adding it if it is, as it will // become ambiguous as objects with no name are assigned name "null" if (Strings.isNullOrEmpty(name) || name.equals("null")) { return; } markObject(objectDefinition, name, object); }
Example #26
Source File: ClueScrollPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(final MenuOptionClicked event) { if (event.getMenuOption() != null && event.getMenuOption().equals("Read")) { final ItemComposition itemComposition = itemManager.getItemComposition(event.getId()); if (itemComposition != null && (itemComposition.getName().startsWith("Clue scroll") || itemComposition.getName().startsWith("Challenge scroll"))) { clueItemId = itemComposition.getId(); updateClue(MapClue.forItemId(clueItemId)); } } }
Example #27
Source File: FriendNotesPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { final int groupId = WidgetInfo.TO_GROUP(event.getWidgetId()); if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.IGNORE_LIST.getGroupId()) { if (Strings.isNullOrEmpty(event.getMenuTarget())) { return; } // Handle clicks on "Add Note" or "Edit Note" if (event.getMenuOption().equals(ADD_NOTE) || event.getMenuOption().equals(EDIT_NOTE)) { event.consume(); //Friends have color tags final String sanitizedTarget = Text.toJagexName(Text.removeTags(event.getMenuTarget())); final String note = getFriendNote(sanitizedTarget); // Open the new chatbox input dialog chatboxPanelManager.openTextInput(String.format(NOTE_PROMPT_FORMAT, sanitizedTarget, CHARACTER_LIMIT)) .value(Strings.nullToEmpty(note)) .onDone((content) -> { if (content == null) { return; } content = Text.removeTags(content).trim(); log.debug("Set note for '{}': '{}'", sanitizedTarget, content); setFriendNote(sanitizedTarget, content); }).build(); } } }
Example #28
Source File: NpcIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked click) { if (click.getMenuAction() != MenuAction.RUNELITE || !(click.getMenuOption().equals(TAG) || click.getMenuOption().equals(UNTAG))) { return; } final int id = click.getId(); final boolean removed = npcTags.remove(id); final NPC[] cachedNPCs = client.getCachedNPCs(); final NPC npc = cachedNPCs[id]; if (npc == null || npc.getName() == null) { return; } if (removed) { highlightedNpcs.remove(npc); memorizedNpcs.remove(npc.getIndex()); } else { if (!client.isInInstancedRegion()) { memorizeNpc(npc); npcTags.add(id); } highlightedNpcs.add(npc); } click.consume(); }
Example #29
Source File: XpTrackerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { if (event.getMenuAction().getId() != MenuAction.RUNELITE.getId() || TO_GROUP(event.getWidgetId()) != WidgetID.SKILLS_GROUP_ID) { return; } final Skill skill; try { skill = Skill.valueOf(Text.removeTags(event.getMenuTarget()).toUpperCase()); } catch (IllegalArgumentException ex) { log.debug(null, ex); return; } switch (event.getMenuOption()) { case MENUOP_ADD_CANVAS_TRACKER: addOverlay(skill); break; case MENUOP_REMOVE_CANVAS_TRACKER: removeOverlay(skill); break; } }
Example #30
Source File: GroundItemsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) { if (menuOptionClicked.getMenuAction() == MenuAction.ITEM_DROP) { int itemId = menuOptionClicked.getId(); // Keep a queue of recently dropped items to better detect // item spawns that are drops droppedItemQueue.add(itemId); } }