Java Code Examples for net.runelite.api.events.MenuOptionClicked#getMenuOpcode()
The following examples show how to use
net.runelite.api.events.MenuOptionClicked#getMenuOpcode() .
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: 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 2
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 3
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 4
Source File: KourendLibraryPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked menuOpt) { if (MenuOpcode.GAME_OBJECT_FIRST_OPTION == menuOpt.getMenuOpcode() && menuOpt.getTarget().contains("Bookshelf")) { lastBookcaseClick = WorldPoint.fromScene(client, menuOpt.getParam0(), menuOpt.getParam1(), client.getPlane()); } }
Example 5
Source File: ObjectIndicatorsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { if (event.getMenuOpcode() != MenuOpcode.RUNELITE || !(event.getOption().equals(MARK) || event.getOption().equals(UNMARK))) { return; } Scene scene = client.getScene(); Tile[][][] tiles = scene.getTiles(); final int x = event.getParam0(); final int y = event.getParam1(); final int z = client.getPlane(); final Tile tile = tiles[z][x][y]; TileObject object = findTileObject(tile, event.getIdentifier()); if (object == null) { return; } // object.getId() is always the base object id, getObjectDefinition transforms it to // the correct object we see ObjectDefinition objectDefinition = getObjectDefinition(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 6
Source File: SlayermusiqPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked ev) { if (ev.getMenuOpcode() == MenuOpcode.RUNELITE && ev.getOption().equals(MENUOP_SLAYERMUSIQ)) { ev.consume(); String quest = Text.removeTags(ev.getTarget()); QuestGuideLinks.tryOpenGuide(quest, chatMessageManager); } }
Example 7
Source File: MiningPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { //TODO: should work hopefully if (event.getMenuOpcode() != MenuOpcode.RUNELITE || event.getParam1() != WidgetInfo.INVENTORY.getId()) { return; } ItemContainer inventoryItemContainer = client.getItemContainer(InventoryID.INVENTORY); Item[] inventoryItems = new Item[0]; if (inventoryItemContainer != null) { inventoryItems = inventoryItemContainer.getItems(); } switch (event.getOption().toLowerCase()) { case FILL_OPTION: int coalInInventoryCount = (int) Arrays.stream(inventoryItems).filter(i -> i.getId() == ItemID.COAL).count(); updateAmountOfCoalInBag(coalInInventoryCount); break; case EMPTY_OPTION: int emptyInventorySpaceCount = (int) Arrays.stream(inventoryItems).filter(i -> i.getId() != -1).count(); int difference = MAX_INVENTORY_SPACE - emptyInventorySpaceCount; updateAmountOfCoalInBag(-difference); break; } }
Example 8
Source File: NpcIndicatorsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked click) { if (click.getMenuOpcode() != MenuOpcode.RUNELITE || !(click.getOption().equals(TAG) || click.getOption().equals(UNTAG))) { return; } final int id = click.getIdentifier(); 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) { MemorizedNpc mn = memorizedNpcs.get(npc.getIndex()); if (mn != null && isNpcMemorizationUnnecessary(mn)) { memorizedNpcs.remove(npc.getIndex()); rebuildAllNpcs(); } } else { npcTags.add(id); rebuildAllNpcs(); } click.consume(); }
Example 9
Source File: GroundItemsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) { if (menuOptionClicked.getMenuOpcode() == MenuOpcode.ITEM_DROP) { int itemId = menuOptionClicked.getIdentifier(); // Keep a queue of recently dropped items to better detect // item spawns that are drops droppedItemQueue.add(itemId); } }
Example 10
Source File: WikiPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked ev) { if (ev.getMenuOpcode() == MenuOpcode.RUNELITE) { checkQuestClicked(ev); } if (!wikiSelected) { return; } onDeselect(); client.setSpellSelected(false); ev.consume(); String type; int id; String name; WorldPoint location; switch (ev.getMenuOpcode()) { case RUNELITE: case CANCEL: return; case ITEM_USE_ON_WIDGET: case SPELL_CAST_ON_GROUND_ITEM: { type = "item"; id = itemManager.canonicalize(ev.getIdentifier()); name = itemManager.getItemDefinition(id).getName(); location = null; break; } case SPELL_CAST_ON_NPC: { type = "npc"; NPC npc = client.getCachedNPCs()[ev.getIdentifier()]; NPCDefinition nc = npc.getTransformedDefinition(); id = nc.getId(); name = nc.getName(); location = npc.getWorldLocation(); break; } case SPELL_CAST_ON_GAME_OBJECT: { type = "object"; ObjectDefinition lc = client.getObjectDefinition(ev.getIdentifier()); if (lc.getImpostorIds() != null) { lc = lc.getImpostor(); } id = lc.getId(); name = lc.getName(); location = WorldPoint.fromScene(client, ev.getParam0(), ev.getParam1(), client.getPlane()); break; } case SPELL_CAST_ON_WIDGET: { Widget w = getWidget(ev.getParam1(), ev.getParam0()); if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1) { type = "item"; id = itemManager.canonicalize(w.getItemId()); name = itemManager.getItemDefinition(id).getName(); location = null; break; } } // fallthrough default: log.info("Unknown menu option: {} {} {}", ev, ev.getMenuOpcode(), ev.getMenuOpcode() == MenuOpcode.CANCEL); return; } name = Text.removeTags(name); HttpUrl.Builder urlBuilder = WIKI_BASE.newBuilder(); urlBuilder.addPathSegments("w/Special:Lookup") .addQueryParameter("type", type) .addQueryParameter("id", "" + id) .addQueryParameter("name", name) .addQueryParameter(UTM_SOURCE_KEY, UTM_SOURCE_VALUE); if (location != null) { urlBuilder.addQueryParameter("x", "" + location.getX()) .addQueryParameter("y", "" + location.getY()) .addQueryParameter("plane", "" + location.getPlane()); } HttpUrl url = urlBuilder.build(); LinkBrowser.browse(url.toString()); }
Example 11
Source File: ExaminePlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe void onMenuOptionClicked(MenuOptionClicked event) { if (!event.getOption().equals("Examine")) { return; } ExamineType type; int id, quantity = -1; switch (event.getMenuOpcode()) { case EXAMINE_ITEM: { type = ExamineType.ITEM; id = event.getIdentifier(); int widgetId = event.getParam1(); int widgetGroup = TO_GROUP(widgetId); int widgetChild = TO_CHILD(widgetId); Widget widget = client.getWidget(widgetGroup, widgetChild); WidgetItem widgetItem = widget.getWidgetItem(event.getParam0()); quantity = widgetItem != null && widgetItem.getId() >= 0 ? widgetItem.getQuantity() : 1; break; } case EXAMINE_ITEM_GROUND: type = ExamineType.ITEM; id = event.getIdentifier(); break; case CC_OP_LOW_PRIORITY: { type = ExamineType.ITEM_BANK_EQ; int[] qi = findItemFromWidget(event.getParam1(), event.getParam0()); if (qi == null) { log.debug("Examine for item with unknown widget: {}", event); return; } quantity = qi[0]; id = qi[1]; break; } case EXAMINE_OBJECT: type = ExamineType.OBJECT; id = event.getIdentifier(); break; case EXAMINE_NPC: type = ExamineType.NPC; id = event.getIdentifier(); break; default: return; } PendingExamine pendingExamine = new PendingExamine(); pendingExamine.setType(type); pendingExamine.setId(id); pendingExamine.setQuantity(quantity); pendingExamine.setCreated(Instant.now()); pending.push(pendingExamine); }
Example 12
Source File: BankTagsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { if (event.getParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getMenuOpcode() == MenuOpcode.RUNELITE && event.getOption().startsWith(EDIT_TAGS_MENU_OPTION)) { event.consume(); int inventoryIndex = event.getParam0(); ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK); if (bankContainer == null) { return; } Item[] items = bankContainer.getItems(); if (inventoryIndex < 0 || inventoryIndex >= items.length) { return; } Item item = bankContainer.getItems()[inventoryIndex]; if (item == null) { return; } int itemId = item.getId(); ItemDefinition itemDefinition = itemManager.getItemDefinition(itemId); String name = itemDefinition.getName(); // Get both tags and vartags and append * to end of vartags name Collection<String> tags = tagManager.getTags(itemId, false); tagManager.getTags(itemId, true).stream() .map(i -> i + "*") .forEach(tags::add); boolean isSearchOpen = client.getVar(VarClientInt.INPUT_TYPE) == InputType.SEARCH.getType(); String searchText = client.getVar(VarClientStr.INPUT_TEXT); String initialValue = Text.toCSV(tags); chatboxPanelManager.openTextInput(name + " tags:<br>(append " + VAR_TAG_SUFFIX + " for variation tag)") .addCharValidator(FILTERED_CHARS) .value(initialValue) .onDone((Consumer<String>) (newValue) -> clientThread.invoke(() -> { // Split inputted tags to vartags (ending with *) and regular tags final Collection<String> newTags = new ArrayList<>(Text.fromCSV(newValue.toLowerCase())); final Collection<String> newVarTags = new ArrayList<>(newTags).stream().filter(s -> s.endsWith(VAR_TAG_SUFFIX)).map(s -> { newTags.remove(s); return s.substring(0, s.length() - VAR_TAG_SUFFIX.length()); }).collect(Collectors.toList()); // And save them tagManager.setTagString(itemId, Text.toCSV(newTags), false); tagManager.setTagString(itemId, Text.toCSV(newVarTags), true); // Check both previous and current tags in case the tag got removed in new tags or in case // the tag got added in new tags tabInterface.updateTabIfActive(Text.fromCSV(initialValue.toLowerCase().replaceAll(Pattern.quote(VAR_TAG_SUFFIX), ""))); tabInterface.updateTabIfActive(Text.fromCSV(newValue.toLowerCase().replaceAll(Pattern.quote(VAR_TAG_SUFFIX), ""))); })) .build(); if (isSearchOpen) { bankSearch.reset(false); bankSearch.search(InputType.SEARCH, searchText, false); } } else { tabInterface.handleClick(event); } }