Java Code Examples for net.runelite.api.MenuEntry#setOption()
The following examples show how to use
net.runelite.api.MenuEntry#setOption() .
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: Runes.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.findItem(id).getLeft() == -1) { return; } if (!plugin.isImbue() && plugin.isEnableImbue()) { event.setOption("Use"); event.setTarget("<col=ff9040>Magic Imbue<col=ffffff> -> <col=ffff>Yourself"); event.setForceLeftClick(true); return; } event.setOption("Use"); event.setTarget(rune); event.setForceLeftClick(true); }
Example 2
Source File: Healer.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.getRoleText() == null || plugin.getRoleText().isBlank() || plugin.getRoleText().isEmpty() || plugin.getRoleText().equals("- - -")) { return; } int id = ITEMS.getOrDefault(plugin.getRoleText(), -1); if (id == -1) { log.error("This shouldn't be possible, bad string: {}", plugin.getRoleText()); return; } event.setOption("Use"); event.setTarget("<col=ff9040>Food<col=ffffff> -> <col=ffff00>Penance Healer"); event.setForceLeftClick(true); }
Example 3
Source File: CameraPlugin.java From plugins with GNU General Public License v3.0 | 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.setOpcode(MenuOpcode.CC_OP.getId()); m.setParam0(lookNorth.getParam0()); m.setParam1(lookNorth.getParam1()); return m; }
Example 4
Source File: Karambwans.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.findItem(ItemID.RAW_KARAMBWAN).getLeft() == -1) { return; } event.setOption("Use"); event.setTarget("<col=ff9040>Raw karambwan<col=ffffff> -> " + event.getTarget()); event.setForceLeftClick(true); }
Example 5
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 6
Source File: Birdhouses.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.findItem(HOPS_SEED).getLeft() == -1) { return; } event.setOption("Use"); event.setTarget("<col=ff9040>Hops seed<col=ffffff> -> " + plugin.getTargetMap().get(event.getIdentifier())); event.setOpcode(MenuOpcode.ITEM_USE_ON_GAME_OBJECT.getId()); event.setForceLeftClick(true); }
Example 7
Source File: Tiara.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.findItem(ItemID.TIARA).getLeft() == -1) { return; } event.setOption("Use"); event.setTarget("<col=ff9040>Tiara<col=ffffff> -> <col=ffff>Altar"); event.setForceLeftClick(true); }
Example 8
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 9
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 10
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 11
Source File: XpTrackerPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(final MenuEntryAdded event) { int widgetID = event.getParam1(); 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.getParam0()); menuEntry.setParam1(widgetID); menuEntry.setOpcode(MenuOpcode.RUNELITE.getId()); client.setMenuEntries(menuEntries); }
Example 12
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 13
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 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: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
public void handleDrag(boolean isDragging, boolean shiftDown) { if (isHidden()) { return; } Widget draggedOn = client.getDraggedOnWidget(); Widget draggedWidget = client.getDraggedWidget(); if (!isDragging || draggedOn == null) { return; } // is dragging widget and mouse button released if (client.getMouseCurrentButton() == 0) { if (!isTabMenuActive() && draggedWidget.getItemId() > 0 && draggedWidget.getId() != parent.getId()) { // Tag an item dragged on a tag tab if (draggedOn.getId() == parent.getId()) { tagManager.addTag(draggedWidget.getItemId(), draggedOn.getName(), shiftDown); updateTabIfActive(Lists.newArrayList(Text.standardize(draggedOn.getName()))); } } else if ((isTabMenuActive() && draggedWidget.getId() == draggedOn.getId() && draggedOn.getId() != parent.getId()) || (parent.getId() == draggedOn.getId() && parent.getId() == draggedWidget.getId())) { // Reorder tag tabs moveTagTab(draggedWidget, draggedOn); } } else if (draggedWidget.getItemId() > 0) { MenuEntry[] entries = client.getMenuEntries(); if (entries.length > 0) { MenuEntry entry = entries[entries.length - 1]; if (draggedWidget.getItemId() > 0 && entry.getOption().equals(VIEW_TAB) && draggedOn.getId() != draggedWidget.getId()) { entry.setOption(TAG_SEARCH + Text.removeTags(entry.getTarget()) + (shiftDown ? VAR_TAG_SUFFIX : "")); entry.setTarget(draggedWidget.getName()); client.setMenuEntries(entries); } if (entry.getOption().equals(SCROLL_UP)) { scrollTick(-1); } else if (entry.getOption().equals(SCROLL_DOWN)) { scrollTick(1); } } } }
Example 16
Source File: WorldHopperPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 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()) { boolean after; if (AFTER_OPTIONS.contains(option)) { after = true; } else if (BEFORE_OPTIONS.contains(option)) { after = false; } else { return; } // Don't add entry if user is offline ChatPlayer player = getChatPlayerFromName(event.getTarget()); WorldResult worldResult = worldService.getWorlds(); if (player == null || player.getWorld() == 0 || player.getWorld() == client.getWorld() || worldResult == null) { return; } World currentWorld = worldResult.findWorld(client.getWorld()); World targetWorld = worldResult.findWorld(player.getWorld()); if (targetWorld == null || currentWorld == null || (!currentWorld.getTypes().contains(WorldType.PVP) && targetWorld.getTypes().contains(WorldType.PVP))) { // Disable Hop-to a PVP world from a regular world return; } final MenuEntry hopTo = new MenuEntry(); hopTo.setOption(HOP_TO); hopTo.setTarget(event.getTarget()); hopTo.setType(MenuAction.RUNELITE.getId()); hopTo.setParam0(event.getActionParam0()); hopTo.setParam1(event.getActionParam1()); insertMenuEntry(hopTo, client.getMenuEntries(), after); } }
Example 17
Source File: InventoryTagsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuOpened(final MenuOpened event) { final MenuEntry firstEntry = event.getFirstEntry(); if (firstEntry == null) { return; } final int widgetId = firstEntry.getParam1(); // Inventory item menu if (widgetId == WidgetInfo.INVENTORY.getId() && editorMode) { int itemId = firstEntry.getIdentifier(); if (itemId == -1) { return; } MenuEntry[] menuList = new MenuEntry[GROUPS.size() + 1]; int num = 0; // preserve the 'Cancel' option as the client will reuse the first entry for Cancel and only resets option/action menuList[num++] = event.getMenuEntries()[0]; for (final String groupName : GROUPS) { final String group = getTag(itemId); final MenuEntry newMenu = new MenuEntry(); final Color color = getGroupNameColor(groupName); newMenu.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET); newMenu.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE))); newMenu.setIdentifier(itemId); newMenu.setParam1(widgetId); newMenu.setType(MenuAction.RUNELITE.getId()); menuList[num++] = newMenu; } client.setMenuEntries(menuList); } }
Example 18
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 4 votes |
public void handleDrag(boolean isDragging, boolean shiftDown) { if (isHidden()) { return; } Widget draggedOn = client.getDraggedOnWidget(); Widget draggedWidget = client.getDraggedWidget(); // round-about way to prevent drag reordering when in a tag tab, now that it looks like a normal tab // returning early from drag release and nulling out the drag release listener have no effect, // probably a better way to do this though if (draggedWidget.getId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && isActive() && config.removeSeparators()) { client.setDraggedOnWidget(null); } if (!isDragging || draggedOn == null) { return; } // is dragging widget and mouse button released if (client.getMouseCurrentButton() == 0) { if (!isTabMenuActive() && draggedWidget.getItemId() > 0 && draggedWidget.getId() != parent.getId()) { // Tag an item dragged on a tag tab if (draggedOn.getId() == parent.getId()) { tagManager.addTag(draggedWidget.getItemId(), draggedOn.getName(), shiftDown); updateTabIfActive(Lists.newArrayList(Text.standardize(draggedOn.getName()))); } } else if ((isTabMenuActive() && draggedWidget.getId() == draggedOn.getId() && draggedOn.getId() != parent.getId()) || (parent.getId() == draggedOn.getId() && parent.getId() == draggedWidget.getId())) { moveTagTab(draggedWidget, draggedOn); } } else if (draggedWidget.getItemId() > 0) { MenuEntry[] entries = client.getMenuEntries(); if (entries.length > 0) { MenuEntry entry = entries[entries.length - 1]; if (draggedWidget.getItemId() > 0 && entry.getOption().equals(VIEW_TAB) && draggedOn.getId() != draggedWidget.getId()) { entry.setOption(TAG_SEARCH + Text.removeTags(entry.getTarget()) + (shiftDown ? VAR_TAG_SUFFIX : "")); entry.setTarget(draggedWidget.getName()); client.setMenuEntries(entries); } if (entry.getOption().equals(SCROLL_UP)) { scrollTick(-1); } else if (entry.getOption().equals(SCROLL_DOWN)) { scrollTick(1); } } } }
Example 19
Source File: InventoryTagsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuOpened(final MenuOpened event) { final MenuEntry firstEntry = event.getFirstEntry(); if (firstEntry == null) { return; } final int widgetId = firstEntry.getParam1(); // Inventory item menu if (widgetId == WidgetInfo.INVENTORY.getId() && editorMode) { int itemId = firstEntry.getIdentifier(); if (itemId == -1) { return; } MenuEntry[] menuList = new MenuEntry[config.getAmount().toInt() + 1]; int num = 0; // preserve the 'Cancel' option as the client will reuse the first entry for Cancel and only resets option/action menuList[num++] = event.getMenuEntries()[0]; List<String> groups = GROUPS.subList(Math.max(GROUPS.size() - config.getAmount().toInt(), 0), GROUPS.size()); for (final String groupName : groups) { final String group = getTag(itemId); final MenuEntry newMenu = new MenuEntry(); final Color color = getGroupNameColor(groupName); newMenu.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET); newMenu.setTarget(ColorUtil.prependColorTag(groupName, Objects.requireNonNullElse(color, Color.WHITE))); newMenu.setIdentifier(itemId); newMenu.setParam1(widgetId); newMenu.setOpcode(MenuOpcode.RUNELITE.getId()); menuList[num++] = newMenu; } // Need to set the event entries to prevent conflicts event.setMenuEntries(menuList); event.setModified(); } }
Example 20
Source File: GroundItemsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (config.itemHighlightMode() != OVERLAY) { final boolean telegrabEntry = event.getOption().equals("Cast") && event.getTarget().startsWith(TELEGRAB_TEXT) && event.getType() == CAST_ON_ITEM; if (!(event.getOption().equals("Take") && event.getType() == THIRD_OPTION) && !telegrabEntry) { return; } final int itemId = event.getIdentifier(); final int sceneX = event.getActionParam0(); final int sceneY = event.getActionParam1(); MenuEntry[] menuEntries = client.getMenuEntries(); MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; final WorldPoint worldPoint = WorldPoint.fromScene(client, sceneX, sceneY, client.getPlane()); GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemId, worldPoint); GroundItem groundItem = collectedGroundItems.get(groundItemKey); int quantity = groundItem.getQuantity(); final int gePrice = groundItem.getGePrice(); final int haPrice = groundItem.getHaPrice(); final Color hidden = getHidden(new NamedQuantity(groundItem.getName(), quantity), gePrice, haPrice, groundItem.isTradeable()); final Color highlighted = getHighlighted(new NamedQuantity(groundItem.getName(), quantity), gePrice, haPrice); final Color color = getItemColor(highlighted, hidden); final boolean canBeRecolored = highlighted != null || (hidden != null && config.recolorMenuHiddenItems()); if (color != null && canBeRecolored && !color.equals(config.defaultColor())) { final MenuHighlightMode mode = config.menuHighlightMode(); if (mode == BOTH || mode == OPTION) { final String optionText = telegrabEntry ? "Cast" : "Take"; lastEntry.setOption(ColorUtil.prependColorTag(optionText, color)); } if (mode == BOTH || mode == NAME) { String target = lastEntry.getTarget(); if (telegrabEntry) { target = target.substring(TELEGRAB_TEXT.length()); } target = ColorUtil.prependColorTag(target.substring(target.indexOf('>') + 1), color); if (telegrabEntry) { target = TELEGRAB_TEXT + target; } lastEntry.setTarget(target); } } if (config.showMenuItemQuantities() && groundItem.isStackable() && quantity > 1) { lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")"); } client.setMenuEntries(menuEntries); } }