Java Code Examples for net.runelite.api.events.MenuOptionClicked#consume()
The following examples show how to use
net.runelite.api.events.MenuOptionClicked#consume() .
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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
Source File: OneClickPlugin.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { if (tick) { event.consume(); return; } if (event.getTarget() == null) { return; } if (config.customInvSwap() && event.getOpcode() == MenuOpcode.ITEM_USE.getId() && customClickMap.containsKey(event.getIdentifier()) && updateSelectedItem(customClickMap.get(event.getIdentifier())) ) { event.setOpcode(MenuOpcode.ITEM_USE_ON_WIDGET_ITEM.getId()); return; } if (comparable == null) { log.error("This should not be possible."); throw new AssertionError(); } if (comparable.isEntryValid(event)) { comparable.modifyEntry(this, event); } if (comparable.isClickValid(event)) { comparable.modifyClick(this, event); } }
Example 9
Source File: FriendNotesPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { if (WidgetInfo.TO_GROUP(event.getParam1()) == WidgetInfo.FRIENDS_LIST.getGroupId()) { if (Strings.isNullOrEmpty(event.getTarget())) { return; } // Handle clicks on "Add Note" or "Edit Note" if (event.getOption().equals(ADD_NOTE) || event.getOption().equals(EDIT_NOTE)) { event.consume(); //Friends have color tags final String sanitizedTarget = Text.toJagexName(Text.removeTags(event.getTarget())); 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 10
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 11
Source File: PartyPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private 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; break; } } if (!isOnCanvas) { return; } event.consume(); final TilePing tilePing = new TilePing(selectedSceneTile.getWorldLocation()); tilePing.setMemberId(party.getLocalMember().getMemberId()); wsClient.send(tilePing); }
Example 12
Source File: FriendTaggingPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { if (WidgetInfo.TO_GROUP(event.getParam1()) == WidgetInfo.FRIENDS_LIST.getGroupId()) { if (Strings.isNullOrEmpty(event.getTarget())) { return; } final String sanitizedTarget = Text.removeTags(event.getTarget()); if (event.getOption().equals(ADD_TAG)) { event.consume(); final ChatboxTextInput build = chatboxPanelManager.openTextInput("Enter the tag").value("") .onDone((content) -> { if (content == null) { return; } content = Text.removeTags(content).trim(); setTag(sanitizedTarget, content); }).build(); } if (event.getOption().equals(DELETE_TAG)) { event.consume(); client.getLogger().info(sanitizedTarget); taggedFriends.forEach((k, v) -> client.getLogger().info(k + ": ", v)); deleteTag(sanitizedTarget); } } }
Example 13
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 14
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 15
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 16
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
public void handleClick(MenuOptionClicked event) { if (isHidden()) { return; } if (chatboxPanelManager.getCurrentInput() != null && event.getMenuAction() != MenuAction.CANCEL && !event.getMenuOption().equals(SCROLL_UP) && !event.getMenuOption().equals(SCROLL_DOWN)) { chatboxPanelManager.close(); } if ((event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() || event.getWidgetId() == WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getId()) && event.getMenuAction() == MenuAction.CC_OP_LOW_PRIORITY && (event.getMenuOption().equalsIgnoreCase("withdraw-x") || event.getMenuOption().equalsIgnoreCase("deposit-x"))) { waitSearchTick = true; rememberedSearch = client.getVar(VarClientStr.INPUT_TEXT); bankSearch.search(InputType.NONE, rememberedSearch, true); } if (activeTab != null && event.getMenuOption().equals("Search") && client.getWidget(WidgetInfo.BANK_SEARCH_BUTTON_BACKGROUND).getSpriteId() != SpriteID.EQUIPMENT_SLOT_SELECTED) { activateTab(null); // This ensures that when clicking Search when tab is selected, the search input is opened rather // than client trying to close it first client.setVar(VarClientStr.INPUT_TEXT, ""); client.setVar(VarClientInt.INPUT_TYPE, 0); } else if (activeTab != null && event.getMenuOption().startsWith("View tab")) { activateTab(null); } else if (activeTab != null && event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getMenuAction() == MenuAction.RUNELITE && event.getMenuOption().startsWith(REMOVE_TAG)) { // Add "remove" menu entry to all items in bank while tab is selected event.consume(); final ItemComposition item = getItem(event.getActionParam()); final int itemId = item.getId(); tagManager.removeTag(itemId, activeTab.getTag()); bankSearch.search(InputType.SEARCH, TAG_SEARCH + activeTab.getTag(), true); } else if (event.getMenuAction() == MenuAction.RUNELITE && ((event.getWidgetId() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId() && event.getMenuOption().equals(TAG_INVENTORY)) || (event.getWidgetId() == WidgetInfo.BANK_DEPOSIT_EQUIPMENT.getId() && event.getMenuOption().equals(TAG_GEAR)))) { handleDeposit(event, event.getWidgetId() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId()); } else if (activeTab != null && ((event.getWidgetId() == WidgetInfo.BANK_EQUIPMENT_BUTTON.getId() && event.getMenuOption().equals(SHOW_WORN)) || (event.getWidgetId() == WidgetInfo.BANK_SETTINGS_BUTTON.getId() && event.getMenuOption().equals(SHOW_SETTINGS)) || (event.getWidgetId() == WidgetInfo.BANK_TUTORIAL_BUTTON.getId() && event.getMenuOption().equals(SHOW_TUTORIAL)))) { saveTab(); rememberedSearch = TAG_SEARCH + activeTab.getTag(); } else if (!Strings.isNullOrEmpty(rememberedSearch) && ((event.getWidgetId() == WidgetInfo.BANK_EQUIPMENT_BUTTON.getId() && event.getMenuOption().equals(HIDE_WORN)) || (event.getWidgetId() == WidgetInfo.BANK_SETTINGS_BUTTON.getId() && event.getMenuOption().equals(HIDE_SETTINGS)))) { bankSearch.reset(true); bankSearch.search(InputType.NONE, rememberedSearch, true); rememberedSearch = ""; } }
Example 17
Source File: BankTagsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { if (event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getMenuAction() == MenuAction.RUNELITE && event.getMenuOption().startsWith(EDIT_TAGS_MENU_OPTION)) { event.consume(); int inventoryIndex = event.getActionParam(); 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(); ItemComposition itemComposition = itemManager.getItemComposition(itemId); String name = itemComposition.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); } }