Java Code Examples for net.runelite.api.events.MenuEntryAdded#setModified()
The following examples show how to use
net.runelite.api.events.MenuEntryAdded#setModified() .
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: CorpPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if (event.getOpcode() != NPC_SECOND_OPTION.getId() || !config.leftClickCore() || !event.getOption().equals(ATTACK)) { return; } final int npcIndex = event.getIdentifier(); final NPC npc = client.getCachedNPCs()[npcIndex]; if (npc == null || !npc.getName().equals(DARK_ENERGY_CORE)) { return; } event.setOpcode(NPC_SECOND_OPTION.getId() + MENU_ACTION_DEPRIORITIZE_OFFSET); event.setModified(); }
Example 2
Source File: DevToolsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded entry) { if (!examine.isActive()) { return; } MenuOpcode action = MenuOpcode.of(entry.getOpcode()); if (EXAMINE_MENU_ACTIONS.contains(action)) { final int identifier = entry.getIdentifier(); String info = "ID: "; if (action == MenuOpcode.EXAMINE_NPC) { NPC npc = client.getCachedNPCs()[identifier]; info += npc.getId(); } else { info += identifier; if (action == MenuOpcode.EXAMINE_OBJECT) { WorldPoint point = WorldPoint.fromScene(client, entry.getParam0(), entry.getParam1(), client.getPlane()); info += " X: " + point.getX() + " Y: " + point.getY(); } } entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET)); entry.setModified(); } }
Example 3
Source File: GrandExchangePlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded menuEntry) { // 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 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.setOpcode(MenuOpcode.RUNELITE.getId()); menuEntry.setModified(); } }
Example 4
Source File: NpcIndicatorsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe void onMenuEntryAdded(MenuEntryAdded event) { int type = event.getOpcode(); if (type >= MENU_ACTION_DEPRIORITIZE_OFFSET) { type -= MENU_ACTION_DEPRIORITIZE_OFFSET; } final MenuOpcode menuOpcode = MenuOpcode.of(type); if (NPC_MENU_ACTIONS.contains(menuOpcode)) { NPC npc = client.getCachedNPCs()[event.getIdentifier()]; Color color = null; if (npc.isDead()) { color = config.deadNpcMenuColor(); } if (color == null && highlightedNpcs.contains(npc) && config.highlightMenuNames() && (!npc.isDead() || !config.ignoreDeadNpcs())) { color = config.getHighlightColor(); } if (color != null) { final String target = ColorUtil.prependColorTag(Text.removeTags(event.getTarget()), color); event.setTarget(target); event.setModified(); } } else if (type == MenuOpcode.EXAMINE_NPC.getId() && client.isKeyPressed(KeyCode.KC_SHIFT)) { // Add tag option client.insertMenuItem( highlightedNpcs.stream().anyMatch(npc -> npc.getIndex() == event.getIdentifier()) ? UNTAG : TAG, event.getTarget(), MenuOpcode.RUNELITE.getId(), event.getIdentifier(), event.getParam0(), event.getParam1(), false ); } }
Example 5
Source File: GroundItemsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded lastEntry) { if (config.itemHighlightMode() != OVERLAY) { final boolean telegrabEntry = lastEntry.getOption().equals("Cast") && lastEntry.getTarget().startsWith(TELEGRAB_TEXT) && lastEntry.getOpcode() == CAST_ON_ITEM; if (!(lastEntry.getOption().equals("Take") && lastEntry.getOpcode() == THIRD_OPTION) && !telegrabEntry) { return; } final int itemId = lastEntry.getIdentifier(); final int sceneX = lastEntry.getParam0(); final int sceneY = lastEntry.getParam1(); 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)); lastEntry.setModified(); } 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); lastEntry.setModified(); } } if (config.showMenuItemQuantities() && groundItem.isStackable() && quantity > 1) { lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")"); lastEntry.setModified(); } if (config.removeIgnored() && lastEntry.getOption().equals("Take") && hiddenItemList.contains(Text.removeTags(lastEntry.getTarget()))) { client.setMenuOptionCount(client.getMenuOptionCount() - 1); } } }
Example 6
Source File: OneClickPlugin.java From ExternalPlugins with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { final int id = event.getIdentifier(); targetMap.put(id, event.getTarget()); if (config.customInvSwap() && customClickMap.getOrDefault(id, null) != null) { if (event.getOpcode() == MenuOpcode.ITEM_USE.getId() && customClickMap.containsKey(id)) { int item = findItem(customClickMap.get(id)).getLeft(); if (item == -1) { return; } final String name = client.getItemDefinition(item).getName(); event.setTarget("<col=ff9040>" + name + "<col=ffffff> -> " + targetMap.get(id)); event.setForceLeftClick(true); event.setModified(); return; } } switch (type) { case SEED_SET: case BA_HEALER: if (event.getOpcode() == MenuOpcode.WALK.getId()) { MenuEntry menuEntry = client.getLeftClickMenuEntry(); menuEntry.setOpcode(MenuOpcode.WALK.getId() + MENU_ACTION_DEPRIORITIZE_OFFSET); client.setLeftClickMenuEntry(menuEntry); } break; default: break; } if (comparable == null) { log.error("This should not be possible."); throw new AssertionError(); } if (type == Types.SPELL && clickItem == null) { return; } if (comparable.isEntryValid(event)) { comparable.modifyEntry(this, event); event.setModified(); } }
Example 7
Source File: LeftClickCast.java From ExternalPlugins with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (event.getOpcode() == MenuOpcode.PLAYER_SECOND_OPTION.getId() && isMage) { final String name = Text.standardize(event.getTarget(), true); if (!config.disableFriendlyRegionChecks() && (client.getVar(Varbits.LMS_IN_GAME) == 0 && (client.isFriended(name, false) || friendsManager.isMember(name)))) { return; } if (!config.disableFriendlyRegionChecks()) { try { boolean b = (!PvPUtil.isAttackable(client, client.getCachedPlayers()[event.getIdentifier()])); } catch (IndexOutOfBoundsException ex) { return; } } event.setModified(); setSelectSpell(currentSpell.getSpell()); event.setOption("(P) Left Click " + client.getSelectedSpellName() + " -> "); } else if (event.getOpcode() == MenuOpcode.NPC_SECOND_OPTION.getId() && isMage) { try { NPC npc = validateNpc(event.getIdentifier()); if (npc == null) { return; } if (config.disableStaffChecks() && !whitelist.contains(npc.getId())) { return; } event.setModified(); setSelectSpell(currentSpell.getSpell()); event.setOption("(N) Left Click " + client.getSelectedSpellName() + " -> "); } catch (IndexOutOfBoundsException ignored) { } } }