net.runelite.api.MenuEntry Java Examples
The following examples show how to use
net.runelite.api.MenuEntry.
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: Seeds.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
@Override public void modifyClick(OneClickPlugin plugin, MenuEntry event) { if (event.getTarget().toLowerCase().contains("tithe")) { if (plugin.updateSelectedItem(SEED_SET)) { event.setOpcode(MenuOpcode.ITEM_USE_ON_GAME_OBJECT.getId()); } } else if (event.getTarget().toLowerCase().contains("water barrel")) { if (plugin.updateSelectedItem(WATERING_CANS)) { event.setOpcode(MenuOpcode.ITEM_USE_ON_GAME_OBJECT.getId()); } } }
Example #4
Source File: OpponentInfoPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { if (menuEntryAdded.getType() != MenuAction.NPC_SECOND_OPTION.getId() || !menuEntryAdded.getOption().equals("Attack") || !config.showOpponentsInMenu()) { return; } int npcIndex = menuEntryAdded.getIdentifier(); NPC npc = client.getCachedNPCs()[npcIndex]; if (npc == null) { return; } if (npc.getInteracting() == client.getLocalPlayer() || lastOpponent == npc) { MenuEntry[] menuEntries = client.getMenuEntries(); menuEntries[menuEntries.length - 1].setTarget("*" + menuEntryAdded.getTarget()); client.setMenuEntries(menuEntries); } }
Example #5
Source File: LearnToClickPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if ((event.getOption().equals("Floating <col=ff9040>World Map</col>") && config.shouldRightClickMap()) || (event.getTarget().equals("<col=ff9040>XP drops</col>") && config.shouldRightClickXp()) || (event.getOption().equals("Auto retaliate") && config.shouldRightClickRetaliate())) { forceRightClickFlag = true; } MenuEntry[] entries = client.getMenuEntries(); if (config.shouldBlockCompass()) { for (int i = entries.length - 1; i >= 0; i--) { if (entries[i].getOption().equals("Look North")) { entries = ArrayUtils.remove(entries, i); i--; } } client.setMenuEntries(entries); } }
Example #6
Source File: LearnToClickPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuShouldLeftClick(MenuShouldLeftClick event) { if (!forceRightClickFlag) { return; } forceRightClickFlag = false; MenuEntry[] menuEntries = client.getMenuEntries(); for (MenuEntry entry : menuEntries) { if ((entry.getOption().equals("Floating <col=ff9040>World Map</col>") && config.shouldRightClickMap()) || (entry.getTarget().equals("<col=ff9040>XP drops</col>") && config.shouldRightClickXp()) || (entry.getOption().equals("Auto retaliate") && config.shouldRightClickRetaliate())) { event.setForceRightClick(true); return; } } }
Example #7
Source File: MenuEntrySwapperPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void swap(ArrayListMultimap<String, Integer> optionIndexes, MenuEntry[] entries, int index1, int index2) { MenuEntry entry1 = entries[index1], entry2 = entries[index2]; entries[index1] = entry2; entries[index2] = entry1; client.setMenuEntries(entries); // Update optionIndexes String option1 = Text.removeTags(entry1.getOption()).toLowerCase(), option2 = Text.removeTags(entry2.getOption()).toLowerCase(); List<Integer> list1 = optionIndexes.get(option1), list2 = optionIndexes.get(option2); // call remove(Object) instead of remove(int) list1.remove((Integer) index1); list2.remove((Integer) index2); sortedInsert(list1, index2); sortedInsert(list2, index1); }
Example #8
Source File: AgilityPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private boolean checkAndModify(MenuEntry old) { //Guarding against non-first option because agility shortcuts are always that type of event. if (old.getOpcode() != MenuOpcode.GAME_OBJECT_FIRST_OPTION.getId()) { return false; } for (Obstacle nearbyObstacle : getObstacles().values()) { AgilityShortcut shortcut = nearbyObstacle.getShortcut(); if (shortcut != null && Ints.contains(shortcut.getObstacleIds(), old.getIdentifier())) { final int reqLevel = shortcut.getLevel(); final String requirementText = ColorUtil.getLevelColorString(reqLevel, getAgilityLevel()) + " (level-" + reqLevel + ")"; old.setTarget(old.getTarget() + requirementText); return true; } } return false; }
Example #9
Source File: CameraPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { if (menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getOption().equals(LOOK_NORTH) && config.compassLook()) { MenuEntry[] menuEntries = client.getMenuEntries(); int len = menuEntries.length; MenuEntry north = menuEntries[len - 1]; menuEntries = Arrays.copyOf(menuEntries, len + 3); // The handling for these entries is done in ToplevelCompassOp.rs2asm menuEntries[--len] = createCameraLookEntry(menuEntryAdded, 4, LOOK_WEST); menuEntries[++len] = createCameraLookEntry(menuEntryAdded, 3, LOOK_EAST); menuEntries[++len] = createCameraLookEntry(menuEntryAdded, 2, LOOK_SOUTH); menuEntries[++len] = north; client.setMenuEntries(menuEntries); } }
Example #10
Source File: GrandExchangeInputListener.java From plugins with GNU General Public License v3.0 | 6 votes |
@Override public MouseEvent mouseClicked(MouseEvent e) { // Check if left click + alt if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown()) { final MenuEntry[] menuEntries = client.getMenuEntries(); for (final MenuEntry menuEntry : menuEntries) { if (menuEntry.getOption().equals(SEARCH_GRAND_EXCHANGE)) { search(Text.removeTags(menuEntry.getTarget())); e.consume(); break; } } } return super.mouseClicked(e); }
Example #11
Source File: MenuEntrySwapperPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void bankModeSwap(int entryTypeId, int entryIdentifier) { MenuEntry[] menuEntries = client.getMenuEntries(); for (int i = menuEntries.length - 1; i >= 0; --i) { MenuEntry entry = menuEntries[i]; if (entry.getType() == entryTypeId && entry.getIdentifier() == entryIdentifier) { // Raise the priority of the op so it doesn't get sorted later entry.setType(MenuAction.CC_OP.getId()); menuEntries[i] = menuEntries[menuEntries.length - 1]; menuEntries[menuEntries.length - 1] = entry; client.setMenuEntries(menuEntries); break; } } }
Example #12
Source File: OverlayRenderer.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private MenuEntry[] createRightClickMenuEntries(Overlay overlay) { List<OverlayMenuEntry> menuEntries = overlay.getMenuEntries(); if (menuEntries.isEmpty()) { return null; } final MenuEntry[] entries = new MenuEntry[menuEntries.size()]; // Add in reverse order so they display correctly in the right-click menu for (int i = menuEntries.size() - 1; i >= 0; --i) { OverlayMenuEntry overlayMenuEntry = menuEntries.get(i); final MenuEntry entry = new MenuEntry(); entry.setOption(overlayMenuEntry.getOption()); entry.setTarget(ColorUtil.wrapWithColorTag(overlayMenuEntry.getTarget(), JagexColors.MENU_TARGET)); entry.setType(overlayMenuEntry.getMenuAction().getId()); entry.setIdentifier(overlayManager.getOverlays().indexOf(overlay)); // overlay id entries[i] = entry; } return entries; }
Example #13
Source File: GrandExchangeInputListener.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Override public MouseEvent mouseClicked(MouseEvent e) { // Check if left click + alt if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown()) { final MenuEntry[] menuEntries = client.getMenuEntries(); for (final MenuEntry menuEntry : menuEntries) { if (menuEntry.getOption().equals(SEARCH_GRAND_EXCHANGE)) { search(Text.removeTags(menuEntry.getTarget())); e.consume(); break; } } } return super.mouseClicked(e); }
Example #14
Source File: WidgetInspector.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if (!pickerSelected) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); for (int i = 0; i < menuEntries.length; i++) { MenuEntry entry = menuEntries[i]; if (entry.getType() != MenuAction.ITEM_USE_ON_WIDGET.getId() && entry.getType() != MenuAction.SPELL_CAST_ON_WIDGET.getId()) { continue; } String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1()); if (entry.getParam0() != -1) { name += " [" + entry.getParam0() + "]"; } Color color = colorForWidget(i, menuEntries.length); entry.setTarget(ColorUtil.wrapWithColorTag(name, color)); } client.setMenuEntries(menuEntries); }
Example #15
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 #16
Source File: Herbtar.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyEntry(OneClickPlugin plugin, MenuEntry event) { if (plugin.findItem(ItemID.SWAMP_TAR).getLeft() == -1 || plugin.findItem(ItemID.PESTLE_AND_MORTAR).getLeft() == -1 ) { return; } event.setTarget("<col=ff9040>Swamp tar<col=ffffff> -> " + plugin.getTargetMap().get(event.getIdentifier())); event.setForceLeftClick(true); }
Example #17
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 #18
Source File: DevToolsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { if (!examine.isActive()) { return; } MenuAction action = MenuAction.of(event.getType()); if (EXAMINE_MENU_ACTIONS.contains(action)) { MenuEntry[] entries = client.getMenuEntries(); MenuEntry entry = entries[entries.length - 1]; final int identifier = event.getIdentifier(); String info = "ID: "; if (action == MenuAction.EXAMINE_NPC) { NPC npc = client.getCachedNPCs()[identifier]; info += npc.getId(); } else { info += identifier; if (action == MenuAction.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)); client.setMenuEntries(entries); } }
Example #19
Source File: Firemaking.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyClick(OneClickPlugin plugin, MenuEntry event) { if (plugin.updateSelectedItem(ItemID.TINDERBOX)) { event.setOpcode(MenuOpcode.ITEM_USE_ON_WIDGET_ITEM.getId()); } }
Example #20
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 #21
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 #22
Source File: WorldHopperPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries, boolean after) { MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry); if (after) { int menuEntryCount = newMenu.length; ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2); } client.setMenuEntries(newMenu); }
Example #23
Source File: WidgetInspector.java From plugins with GNU General Public License v3.0 | 5 votes |
private void onMenuEntryAdded(MenuEntryAdded event) { if (!pickerSelected) { return; } MenuEntry[] menuEntries = client.getMenuEntries(); for (int i = 0; i < menuEntries.length; i++) { MenuEntry entry = menuEntries[i]; if (entry.getOpcode() != MenuOpcode.ITEM_USE_ON_WIDGET.getId() && entry.getOpcode() != MenuOpcode.SPELL_CAST_ON_WIDGET.getId()) { continue; } String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1()); if (entry.getParam0() != -1) { name += " [" + entry.getParam0() + "]"; } Color color = colorForWidget(i, menuEntries.length); entry.setTarget(ColorUtil.wrapWithColorTag(name, color)); } client.setMenuEntries(menuEntries); }
Example #24
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 #25
Source File: Healer.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Override public void modifyClick(OneClickPlugin plugin, MenuEntry event) { if (event.getTarget().equalsIgnoreCase("<col=ff9040>Food<col=ffffff> -> <col=ffff00>Penance Healer")) { if (plugin.updateSelectedItem(ITEMS.getOrDefault(plugin.getRoleText(), -1))) { event.setOpcode(MenuOpcode.ITEM_USE_ON_NPC.getId()); } } }
Example #26
Source File: GrimyHerbComparableEntry.java From plugins with GNU General Public License v3.0 | 5 votes |
public boolean matches(MenuEntry entry) { final int groupId = WidgetInfo.TO_GROUP(entry.getParam1()); if (groupId != WidgetID.INVENTORY_GROUP_ID) { return false; } int cleanLevel; try { cleanLevel = lookup.getCleanLevel(entry.getIdentifier()); } catch (HerbNotFoundException e) { return false; } if (this.mode == SwapGrimyHerbMode.USE) { return StringUtils.equalsIgnoreCase(entry.getOption(), "use"); } String swapOption = "use"; if (client.getBoostedSkillLevel(Skill.HERBLORE) >= cleanLevel) { swapOption = "clean"; } return StringUtils.equalsIgnoreCase(entry.getOption(), swapOption); }
Example #27
Source File: MenuEntrySwapperPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testShiftDeposit() { when(config.bankDepositShiftClick()).thenReturn(ShiftDepositMode.DEPOSIT_ALL); when(client.isKeyPressed(KeyCode.KC_SHIFT)).thenReturn(true); entries = new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Wield", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 9), menu("Deposit-All", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 8), menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2), }; menuEntrySwapperPlugin.onMenuEntryAdded(new MenuEntryAdded( "Deposit-1", "Rune arrow", MenuAction.CC_OP.getId(), 2, -1, -1 )); ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); verify(client).setMenuEntries(argumentCaptor.capture()); assertArrayEquals(new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Wield", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 9), menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2), menu("Deposit-All", "Rune arrow", MenuAction.CC_OP, 8), }, argumentCaptor.getValue()); }
Example #28
Source File: HiscorePlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries) { MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry); int menuEntryCount = newMenu.length; ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2); if (client != null) { client.setMenuEntries(newMenu); } }
Example #29
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 #30
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); } }