Java Code Examples for net.runelite.api.events.MenuOptionClicked#getIdentifier()
The following examples show how to use
net.runelite.api.events.MenuOptionClicked#getIdentifier() .
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: BarbarianAssaultPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { if (!isInGame() && getRole() != null) { return; } String target = Text.removeTags(event.getTarget()).toLowerCase(); if (getRole() == Role.HEALER && (target.startsWith("poisoned meat -> penance healer") || target.startsWith("poisoned tofu -> penance healer") || target.startsWith("poisoned worms -> penance healer"))) { lastHealerPoisoned = event.getIdentifier(); poisonUsed = StringUtils.substringBefore(target.replace("oned", "."), " ->"); } // INW /* String option = Text.removeTags(event.getMenuOption()); if (option.startsWith("Tell-")) { lastClickedTell = getRole().getCallFromTell(option); } else if (usingGloryHorn && option.equals("Call")) { } */ }
Example 2
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 3
Source File: GroundItemsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) { if (menuOptionClicked.getMenuOpcode() == MenuOpcode.ITEM_DROP) { int itemId = menuOptionClicked.getIdentifier(); // Keep a queue of recently dropped items to better detect // item spawns that are drops droppedItemQueue.add(itemId); } }
Example 4
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 5
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 6
Source File: TimersPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { if (config.showStamina() && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.STAMINA_MIX1 || event.getIdentifier() == ItemID.STAMINA_MIX2 || event.getIdentifier() == ItemID.EGNIOL_POTION_1 || event.getIdentifier() == ItemID.EGNIOL_POTION_2 || event.getIdentifier() == ItemID.EGNIOL_POTION_3 || event.getIdentifier() == ItemID.EGNIOL_POTION_4)) { // Needs menu option hook because mixes use a common drink message, distinct from their standard potion messages createStaminaTimer(); return; } if (config.showAntiFire() && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.ANTIFIRE_MIX1 || event.getIdentifier() == ItemID.ANTIFIRE_MIX2)) { // Needs menu option hook because mixes use a common drink message, distinct from their standard potion messages createGameTimer(ANTIFIRE); return; } if (config.showAntiFire() && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.EXTENDED_ANTIFIRE_MIX1 || event.getIdentifier() == ItemID.EXTENDED_ANTIFIRE_MIX2)) { // Needs menu option hook because mixes use a common drink message, distinct from their standard potion messages createGameTimer(EXANTIFIRE); return; } if (config.showAntiFire() && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.SUPER_ANTIFIRE_MIX1 || event.getIdentifier() == ItemID.SUPER_ANTIFIRE_MIX2)) { // Needs menu option hook because mixes use a common drink message, distinct from their standard potion messages createGameTimer(SUPERANTIFIRE); return; } if (config.showAntiFire() && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.EXTENDED_SUPER_ANTIFIRE_MIX1 || event.getIdentifier() == ItemID.EXTENDED_SUPER_ANTIFIRE_MIX2)) { // Needs menu option hook because mixes use a common drink message, distinct from their standard potion messages createGameTimer(EXSUPERANTIFIRE); return; } TeleportWidget teleportWidget = TeleportWidget.of(event.getParam1()); if (teleportWidget != null) { lastTeleportClicked = teleportWidget; } if (config.showImbuedHeart() && event.getOption().contains("Invigorate")) { // Needs a hook as there's a few cases where potions boost the same amount as the heart imbuedHeartClicked = true; } }
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(); } }