Java Code Examples for net.runelite.api.events.MenuOptionClicked#getParam1()
The following examples show how to use
net.runelite.api.events.MenuOptionClicked#getParam1() .
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: 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 2
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 3
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 4
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 5
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); } }
Example 6
Source File: PuzzleSolverPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) { int widgetId = menuOptionClicked.getParam1(); if (TO_GROUP(widgetId) != WidgetID.LIGHT_BOX_GROUP_ID) { return; } Combination combination; if (widgetId == LIGHT_BOX_BUTTON_A.getId()) { clickedThisTick.add("A"); combination = Combination.A; } else if (widgetId == LIGHT_BOX_BUTTON_B.getId()) { clickedThisTick.add("B"); combination = Combination.B; } else if (widgetId == LIGHT_BOX_BUTTON_C.getId()) { clickedThisTick.add("C"); combination = Combination.C; } else if (widgetId == LIGHT_BOX_BUTTON_D.getId()) { clickedThisTick.add("D"); combination = Combination.D; } else if (widgetId == LIGHT_BOX_BUTTON_E.getId()) { clickedThisTick.add("E"); combination = Combination.E; } else if (widgetId == LIGHT_BOX_BUTTON_F.getId()) { clickedThisTick.add("F"); combination = Combination.F; } else if (widgetId == LIGHT_BOX_BUTTON_G.getId()) { clickedThisTick.add("G"); combination = Combination.G; } else if (widgetId == LIGHT_BOX_BUTTON_H.getId()) { clickedThisTick.add("H"); combination = Combination.H; } else { return; } if (lastClick != null) { lastClickInvalid = true; } else { lastClick = combination; } }
Example 7
Source File: LootTrackerPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { // There are some pickpocket targets who show up in the chat box with a different name (e.g. H.A.M. members -> man/woman) // We use the value selected from the right-click menu as a fallback for the event lookup in those cases. if (event.getOption().equals("Pickpocket")) { lastPickpocketTarget = Text.removeTags(event.getTarget()); } if (event.getOption().equals("Take") && event.getIdentifier() == ItemID.SEED_PACK) { eventType = SEEDPACK_EVENT; lootRecordType = LootRecordType.EVENT; takeInventorySnapshot(); } if (event.getParam1() != WidgetInfo.INVENTORY.getId()) { return; } int itemId = event.getIdentifier(); if (itemId == -1) { return; } String option = event.getOption(); ItemDefinition itemComposition = client.getItemDefinition(itemId); if (option.equals("Open") && itemComposition.getName().equals("Supply crate")) { eventType = WINTERTODT_EVENT; takeInventorySnapshot(); } if (option.equals("Open") && SHADE_CHEST_OBJECTS.containsKey(event.getIdentifier())) { eventType = SHADE_CHEST_OBJECTS.get(event.getIdentifier()); lootRecordType = LootRecordType.EVENT; takeInventorySnapshot(); } if (option.equals("Open") && itemId == ItemID.CASKET) { eventType = CASKET_EVENT; lootRecordType = LootRecordType.EVENT; takeInventorySnapshot(); } }