Java Code Examples for net.runelite.api.MenuEntry#setTarget()
The following examples show how to use
net.runelite.api.MenuEntry#setTarget() .
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: 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 2
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 3
Source File: DarkEssence.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.findItem(ItemID.DARK_ESSENCE_BLOCK).getLeft() == -1) { return; } event.setTarget("<col=ff9040>Chisel<col=ffffff> -> <col=ff9040>Dark essence block"); event.setForceLeftClick(true); }
Example 4
Source File: HiscorePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 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() || groupId == WidgetInfo.CHATBOX.getGroupId() && !KICK_OPTION.equals(option) || //prevent from adding for Kick option (interferes with the raiding party one) groupId == WidgetInfo.RAIDING_PARTY.getGroupId() || groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId() || groupId == WidgetInfo.IGNORE_LIST.getGroupId()) { if (!AFTER_OPTIONS.contains(option) || (option.equals("Delete") && groupId != WidgetInfo.IGNORE_LIST.getGroupId())) { return; } final MenuEntry lookup = new MenuEntry(); lookup.setOption(LOOKUP); lookup.setTarget(event.getTarget()); lookup.setType(MenuAction.RUNELITE.getId()); lookup.setParam0(event.getActionParam0()); lookup.setParam1(event.getActionParam1()); lookup.setIdentifier(event.getIdentifier()); insertMenuEntry(lookup, client.getMenuEntries()); } }
Example 5
Source File: Compost.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.findItem(ItemID.COMPOST).getLeft() == -1) { return; } event.setTarget("<col=ff9040>Saltpetre<col=ffffff> -> " + plugin.getTargetMap().get(event.getIdentifier())); event.setForceLeftClick(true); }
Example 6
Source File: Bones.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.findItem(BONE_SET).getLeft() == -1) { return; } event.setOption("Use"); event.setTarget("<col=ff9040>Bones<col=ffffff> -> " + event.getTarget()); event.setForceLeftClick(true); }
Example 7
Source File: SlayermusiqPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private MenuEntry createSlayermusiqOptionMenuEntry(MenuEntryAdded event) { int widgetIndex = event.getParam0(); int widgetID = event.getParam1(); MenuEntry menuEntry = new MenuEntry(); menuEntry.setTarget(event.getTarget()); menuEntry.setOption(MENUOP_SLAYERMUSIQ); menuEntry.setParam0(widgetIndex); menuEntry.setParam1(widgetID); menuEntry.setOpcode(MenuOpcode.RUNELITE.getId()); return menuEntry; }
Example 8
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 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: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private static MenuEntry[] createMenuEntry(MenuEntryAdded event, String option, String target, MenuEntry[] entries) { final MenuEntry entry = new MenuEntry(); entry.setParam0(event.getActionParam0()); entry.setParam1(event.getActionParam1()); entry.setTarget(target); entry.setOption(option); entry.setType(MenuAction.RUNELITE.getId()); entry.setIdentifier(event.getIdentifier()); entries = Arrays.copyOf(entries, entries.length + 1); entries[entries.length - 1] = entry; return entries; }
Example 11
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 12
Source File: ChatHistoryPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded entry) { final ChatboxTab tab = ChatboxTab.of(entry.getParam1()); if (tab == null || !config.clearHistory() || !Text.removeTags(entry.getOption()).equals(tab.getAfter())) { return; } final MenuEntry clearEntry = new MenuEntry(); clearEntry.setTarget(""); clearEntry.setOpcode(MenuOpcode.RUNELITE.getId()); clearEntry.setParam0(entry.getParam0()); clearEntry.setParam1(entry.getParam1()); if (tab == ChatboxTab.GAME) { // keep type as the original CC_OP to correctly group "Game: Clear history" with // other tab "Game: *" options. clearEntry.setOpcode(entry.getOpcode()); } final StringBuilder messageBuilder = new StringBuilder(); if (tab != ChatboxTab.ALL) { messageBuilder.append(ColorUtil.wrapWithColorTag(tab.getName() + ": ", Color.YELLOW)); } messageBuilder.append(CLEAR_HISTORY); clearEntry.setOption(messageBuilder.toString()); final MenuEntry[] menuEntries = client.getMenuEntries(); client.setMenuEntries(ArrayUtils.insert(menuEntries.length - 1, menuEntries, clearEntry)); }
Example 13
Source File: HiscorePlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if (!config.menuOption()) { return; } int groupId = WidgetInfo.TO_GROUP(event.getParam1()); String option = event.getOption(); if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId() || groupId == WidgetInfo.CHATBOX.getGroupId() && !KICK_OPTION.equals(option) || //prevent from adding for Kick option (interferes with the raiding party one) groupId == WidgetInfo.RAIDING_PARTY.getGroupId() || groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId() || groupId == WidgetInfo.IGNORE_LIST.getGroupId()) { if (!AFTER_OPTIONS.contains(option) || (option.equals("Delete") && groupId != WidgetInfo.IGNORE_LIST.getGroupId())) { return; } final MenuEntry lookup = new MenuEntry(); lookup.setOption(LOOKUP); lookup.setTarget(event.getTarget()); lookup.setOpcode(MenuOpcode.RUNELITE.getId()); lookup.setParam0(event.getParam0()); lookup.setParam1(event.getParam1()); lookup.setIdentifier(event.getIdentifier()); if (client != null) { insertMenuEntry(lookup, client.getMenuEntries()); } } }
Example 14
Source File: ChatHistoryPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuOpened(MenuOpened event) { if (event.getMenuEntries().length < 2 || !config.copyToClipboard()) { return; } // Use second entry as first one can be walk here with transparent chatbox final MenuEntry entry = event.getMenuEntries()[event.getMenuEntries().length - 2]; if (entry.getType() != MenuAction.CC_OP_LOW_PRIORITY.getId() && entry.getType() != MenuAction.RUNELITE.getId()) { return; } final int groupId = TO_GROUP(entry.getParam1()); final int childId = TO_CHILD(entry.getParam1()); if (groupId != WidgetInfo.CHATBOX.getGroupId()) { return; } final Widget widget = client.getWidget(groupId, childId); final Widget parent = widget.getParent(); if (WidgetInfo.CHATBOX_MESSAGE_LINES.getId() != parent.getId()) { return; } // Get child id of first chat message static child so we can substract this offset to link to dynamic child // later final int first = WidgetInfo.CHATBOX_FIRST_MESSAGE.getChildId(); // Convert current message static widget id to dynamic widget id of message node with message contents // When message is right clicked, we are actually right clicking static widget that contains only sender. // The actual message contents are stored in dynamic widgets that follow same order as static widgets. // Every first dynamic widget is message sender and every second one is message contents. final int dynamicChildId = (childId - first) * 2 + 1; // Extract and store message contents when menu is opened because dynamic children can change while right click // menu is open and dynamicChildId will be outdated final Widget messageContents = parent.getChild(dynamicChildId); if (messageContents == null) { return; } currentMessage = messageContents.getText(); final MenuEntry menuEntry = new MenuEntry(); menuEntry.setOption(COPY_TO_CLIPBOARD); menuEntry.setTarget(entry.getTarget()); menuEntry.setType(MenuAction.RUNELITE.getId()); menuEntry.setParam0(entry.getParam0()); menuEntry.setParam1(entry.getParam1()); menuEntry.setIdentifier(entry.getIdentifier()); client.setMenuEntries(ArrayUtils.insert(1, client.getMenuEntries(), menuEntry)); }
Example 15
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); } }
Example 16
Source File: ChatHistoryPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onMenuOpened(MenuOpened event) { if (event.getMenuEntries().length < 2 || !config.copyToClipboard()) { return; } // Use second entry as first one can be walk here with transparent chatbox final MenuEntry entry = event.getMenuEntries()[event.getMenuEntries().length - 2]; if (entry.getOpcode() != MenuOpcode.CC_OP_LOW_PRIORITY.getId() && entry.getOpcode() != MenuOpcode.RUNELITE.getId()) { return; } final int groupId = TO_GROUP(entry.getParam1()); final int childId = TO_CHILD(entry.getParam1()); if (groupId != WidgetInfo.CHATBOX.getGroupId()) { return; } final Widget widget = client.getWidget(groupId, childId); final Widget parent = widget.getParent(); if (WidgetInfo.CHATBOX_MESSAGE_LINES.getId() != parent.getId()) { return; } // Get child id of first chat message static child so we can substract this offset to link to dynamic child // later final int first = WidgetInfo.CHATBOX_FIRST_MESSAGE.getChildId(); // Convert current message static widget id to dynamic widget id of message node with message contents // When message is right clicked, we are actually right clicking static widget that contains only sender. // The actual message contents are stored in dynamic widgets that follow same order as static widgets. // Every first dynamic widget is message sender and every second one is message contents. final int dynamicChildId = (childId - first) * 2 + 1; // Extract and store message contents when menu is opened because dynamic children can change while right click // menu is open and dynamicChildId will be outdated final Widget messageContents = parent.getChild(dynamicChildId); if (messageContents == null) { return; } currentMessage = messageContents.getText(); final MenuEntry menuEntry = new MenuEntry(); menuEntry.setOption(COPY_TO_CLIPBOARD); menuEntry.setTarget(entry.getTarget()); menuEntry.setOpcode(MenuOpcode.RUNELITE.getId()); menuEntry.setParam0(entry.getParam0()); menuEntry.setParam1(entry.getParam1()); menuEntry.setIdentifier(entry.getIdentifier()); client.setMenuEntries(ArrayUtils.insert(1, client.getMenuEntries(), menuEntry)); }
Example 17
Source File: WorldHopperPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if (!config.menuOption()) { return; } int groupId = WidgetInfo.TO_GROUP(event.getParam1()); 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) || (config.removePVPWorld() && !currentWorld.getTypes().contains(WorldType.PVP) && targetWorld.getTypes().contains(WorldType.PVP)) || (config.removeBHWorld() && !currentWorld.getTypes().contains(WorldType.BOUNTY) && targetWorld.getTypes().contains(WorldType.BOUNTY))) { // Disable Hop-to a PVP world & BH world from a regular world return; } final MenuEntry hopTo = new MenuEntry(); hopTo.setOption(HOP_TO); hopTo.setTarget(event.getTarget()); hopTo.setOpcode(MenuOpcode.RUNELITE.getId()); hopTo.setParam0(event.getParam0()); hopTo.setParam1(event.getParam1()); insertMenuEntry(hopTo, client.getMenuEntries(), after); } }
Example 18
Source File: OpponentInfoPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private boolean modify(MenuEntry entry) { if (isNotAttackEntry(entry)) { return false; } boolean changed = false; int index = entry.getIdentifier(); Actor actor = getActorFromIndex(index); if (actor == null) { return false; } if (actor instanceof Player) { index -= 32768; } String target = entry.getTarget(); if (showAttacking && client.getLocalPlayer().getRSInteracting() == index) { target = attackingColTag + target.substring(COLOR_TAG_LENGTH); changed = true; } if (showAttackers && actor.getRSInteracting() - 32768 == client.getLocalPlayerIndex()) { target = '*' + target; changed = true; } if (showHitpoints && actor.getHealthScale() > 0) { int lvlIndex = target.lastIndexOf("(level-"); if (lvlIndex != -1) { String levelReplacement = getHpString(actor, true); target = target.substring(0, lvlIndex) + levelReplacement; changed = true; } } if (changed) { entry.setTarget(target); return true; } return false; }
Example 19
Source File: GroundMarkerPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private 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(); int lastIndex = menuEntries.length; menuEntries = Arrays.copyOf(menuEntries, lastIndex + config.getAmount().toInt()); final Tile tile = client.getSelectedSceneTile(); if (tile == null) { return; } final WorldPoint loc = WorldPoint.fromLocalInstance(client, tile.getLocalLocation()); if (loc == null) { return; } final int regionId = loc.getRegionID(); for (int i = config.getAmount().toInt(); i > 0; i--) { MenuEntry menuEntry = menuEntries[lastIndex] = new MenuEntry(); final GroundMarkerPoint point = new GroundMarkerPoint(regionId, loc.getRegionX(), loc.getRegionY(), client.getPlane(), i); final Optional<GroundMarkerPoint> stream = getPoints(regionId).stream().filter(x -> x.equals(point)).findAny(); final String option = (stream.isPresent() && stream.get().getGroup() == i) ? UNMARK : MARK; menuEntry.setOption(ColorUtil.prependColorTag(Text.removeTags(option + (i == 1 ? "" : " (Group " + i + ")")), getColor(i))); menuEntry.setTarget(event.getTarget()); menuEntry.setOpcode(MenuOpcode.RUNELITE.getId()); lastIndex++; } client.setMenuEntries(menuEntries); } }
Example 20
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(); } }