From c0a338519c33328157bb7173780fdcedd44f413d Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Apr 2022 15:53:47 -0400 Subject: [PATCH 01/13] api: refactor some menu action names Replace spell cast with widget use and correct a couple of the other names --- .../java/net/runelite/api/MenuAction.java | 40 +++++++++---------- .../plugins/devtools/WidgetInspector.java | 8 ++-- .../grounditems/GroundItemsPlugin.java | 2 +- .../InteractHighlightOverlay.java | 6 +-- .../InteractHighlightPlugin.java | 6 +-- .../plugins/itemprices/ItemPricesOverlay.java | 2 +- .../mousehighlight/MouseHighlightOverlay.java | 12 +++--- .../npchighlight/NpcIndicatorsPlugin.java | 2 +- .../PlayerIndicatorsPlugin.java | 4 +- .../client/plugins/wiki/WikiPlugin.java | 16 ++++---- 10 files changed, 49 insertions(+), 49 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/MenuAction.java b/runelite-api/src/main/java/net/runelite/api/MenuAction.java index 033eaeedc6..1b636d8856 100644 --- a/runelite-api/src/main/java/net/runelite/api/MenuAction.java +++ b/runelite-api/src/main/java/net/runelite/api/MenuAction.java @@ -37,9 +37,9 @@ public enum MenuAction */ ITEM_USE_ON_GAME_OBJECT(1), /** - * Menu action for casting a spell on a tile object (GameObject or GroundObject). + * Menu action for using a widget on a tile object (GameObject or GroundObject). */ - SPELL_CAST_ON_GAME_OBJECT(2), + WIDGET_TARGET_ON_GAME_OBJECT(2), /** * First menu action for a game object. */ @@ -66,9 +66,9 @@ public enum MenuAction */ ITEM_USE_ON_NPC(7), /** - * Menu action for casting a spell on an NPC. + * Menu action for using a widget on an NPC. */ - SPELL_CAST_ON_NPC(8), + WIDGET_TARGET_ON_NPC(8), /** * First menu action for an NPC. */ @@ -95,18 +95,18 @@ public enum MenuAction */ ITEM_USE_ON_PLAYER(14), /** - * Menu action for casting a spell on a player. + * Menu action for using a widget on a player. */ - SPELL_CAST_ON_PLAYER(15), + WIDGET_TARGET_ON_PLAYER(15), /** * Menu action for using an item on an item on the ground. */ ITEM_USE_ON_GROUND_ITEM(16), /** - * Menu action for casting a spell on an item on the ground. + * Menu action for using a widget on an item on the ground. */ - SPELL_CAST_ON_GROUND_ITEM(17), + WIDGET_TARGET_ON_GROUND_ITEM(17), /** * First menu action for an item on the ground. */ @@ -138,13 +138,13 @@ public enum MenuAction */ WIDGET_TYPE_1(24), /** - * Interaction with widget (type 2). + * Select the widget for targeting other widgets/entites etc. */ - WIDGET_TYPE_2(25), + WIDGET_TARGET(25), /** - * Interaction with widget (type 3). + * Performs an ifclose. */ - WIDGET_TYPE_3(26), + WIDGET_CLOSE(26), /** * Interaction with widget (type 4). */ @@ -154,17 +154,17 @@ public enum MenuAction */ WIDGET_TYPE_5(29), /** - * Interaction with widget (type 6). + * Performs a Continue */ - WIDGET_TYPE_6(30), + WIDGET_CONTINUE(30), /** - * Menu action when using an item on another item inside a widget (inventory). + * Menu action when using an item on another item */ - ITEM_USE_ON_WIDGET_ITEM(31), + ITEM_USE_ON_ITEM(31), /** - * Menu action when using an item on a widget. + * Menu action when using a component on an item */ - ITEM_USE_ON_WIDGET(32), + WIDGET_USE_ON_ITEM(32), /** * First menu action for an item. @@ -227,9 +227,9 @@ public enum MenuAction CC_OP(57), /** - * Casting a spell / op target on a widget + * Using a widget on another widget */ - SPELL_CAST_ON_WIDGET(58), + WIDGET_TARGET_ON_WIDGET(58), /** * Menu action for high priority runelite options diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInspector.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInspector.java index 6e27c99a35..3ae75019d2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInspector.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInspector.java @@ -516,8 +516,8 @@ class WidgetInspector extends DevToolsFrame for (int i = 0; i < menuEntries.length; i++) { MenuEntry entry = menuEntries[i]; - if (entry.getType() != MenuAction.ITEM_USE_ON_WIDGET - && entry.getType() != MenuAction.SPELL_CAST_ON_WIDGET) + if (entry.getType() != MenuAction.WIDGET_USE_ON_ITEM + && entry.getType() != MenuAction.WIDGET_TARGET_ON_WIDGET) { continue; } @@ -543,7 +543,7 @@ class WidgetInspector extends DevToolsFrame Object getWidgetOrWidgetItemForMenuOption(MenuAction type, int param0, int param1) { - if (type == MenuAction.SPELL_CAST_ON_WIDGET) + if (type == MenuAction.WIDGET_TARGET_ON_WIDGET) { Widget w = client.getWidget(param1); if (param0 != -1) @@ -553,7 +553,7 @@ class WidgetInspector extends DevToolsFrame return w; } - else if (type == MenuAction.ITEM_USE_ON_WIDGET) + else if (type == MenuAction.WIDGET_USE_ON_ITEM) { Widget w = client.getWidget(param1); return w.getWidgetItem(param0); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index c4524bf353..2533594e8e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -485,7 +485,7 @@ public class GroundItemsPlugin extends Plugin MenuAction type = MenuAction.of(event.getType()); if (type == MenuAction.GROUND_ITEM_FIRST_OPTION || type == MenuAction.GROUND_ITEM_SECOND_OPTION || type == MenuAction.GROUND_ITEM_THIRD_OPTION || type == MenuAction.GROUND_ITEM_FOURTH_OPTION || - type == MenuAction.GROUND_ITEM_FIFTH_OPTION || type == MenuAction.SPELL_CAST_ON_GROUND_ITEM) + type == MenuAction.GROUND_ITEM_FIFTH_OPTION || type == MenuAction.WIDGET_TARGET_ON_GROUND_ITEM) { final int itemId = event.getIdentifier(); final int sceneX = event.getActionParam0(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightOverlay.java index e401f39d9b..e356939801 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightOverlay.java @@ -85,7 +85,7 @@ class InteractHighlightOverlay extends Overlay switch (menuAction) { case ITEM_USE_ON_GAME_OBJECT: - case SPELL_CAST_ON_GAME_OBJECT: + case WIDGET_TARGET_ON_GAME_OBJECT: case GAME_OBJECT_FIRST_OPTION: case GAME_OBJECT_SECOND_OPTION: case GAME_OBJECT_THIRD_OPTION: @@ -104,7 +104,7 @@ class InteractHighlightOverlay extends Overlay break; } case ITEM_USE_ON_NPC: - case SPELL_CAST_ON_NPC: + case WIDGET_TARGET_ON_NPC: case NPC_FIRST_OPTION: case NPC_SECOND_OPTION: case NPC_THIRD_OPTION: @@ -116,7 +116,7 @@ class InteractHighlightOverlay extends Overlay NPC npc = plugin.findNpc(id); if (npc != null && config.npcShowHover() && (npc != plugin.getInteractedTarget() || !config.npcShowInteract())) { - Color highlightColor = menuAction == MenuAction.NPC_SECOND_OPTION || menuAction == MenuAction.SPELL_CAST_ON_NPC + Color highlightColor = menuAction == MenuAction.NPC_SECOND_OPTION || menuAction == MenuAction.WIDGET_TARGET_ON_NPC ? config.npcAttackHoverHighlightColor() : config.npcHoverHighlightColor(); modelOutlineRenderer.drawOutline(npc, config.borderWidth(), highlightColor, config.outlineFeather()); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightPlugin.java index 026b94301e..1028a8bef7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightPlugin.java @@ -141,7 +141,7 @@ public class InteractHighlightPlugin extends Plugin switch (menuOptionClicked.getMenuAction()) { case ITEM_USE_ON_GAME_OBJECT: - case SPELL_CAST_ON_GAME_OBJECT: + case WIDGET_TARGET_ON_GAME_OBJECT: case GAME_OBJECT_FIRST_OPTION: case GAME_OBJECT_SECOND_OPTION: case GAME_OBJECT_THIRD_OPTION: @@ -158,7 +158,7 @@ public class InteractHighlightPlugin extends Plugin break; } case ITEM_USE_ON_NPC: - case SPELL_CAST_ON_NPC: + case WIDGET_TARGET_ON_NPC: case NPC_FIRST_OPTION: case NPC_SECOND_OPTION: case NPC_THIRD_OPTION: @@ -168,7 +168,7 @@ public class InteractHighlightPlugin extends Plugin int id = menuOptionClicked.getId(); interactedObject = null; interactedNpc = findNpc(id); - attacked = menuOptionClicked.getMenuAction() == MenuAction.NPC_SECOND_OPTION || menuOptionClicked.getMenuAction() == MenuAction.SPELL_CAST_ON_NPC; + attacked = menuOptionClicked.getMenuAction() == MenuAction.NPC_SECOND_OPTION || menuOptionClicked.getMenuAction() == MenuAction.WIDGET_TARGET_ON_NPC; clickTick = client.getTickCount(); gameCycle = client.getGameCycle(); break; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java index bea5de5af5..0b62f029fd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java @@ -98,7 +98,7 @@ class ItemPricesOverlay extends Overlay // Tooltip action type handling switch (action) { - case ITEM_USE_ON_WIDGET: + case WIDGET_USE_ON_ITEM: if (!config.showWhileAlching() || !isAlching) { break; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java index f9355f0aa5..4045d6a0eb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java @@ -49,13 +49,13 @@ class MouseHighlightOverlay extends Overlay */ private static final Set WIDGET_MENU_ACTIONS = ImmutableSet.of( MenuAction.WIDGET_TYPE_1, - MenuAction.WIDGET_TYPE_2, - MenuAction.WIDGET_TYPE_3, + MenuAction.WIDGET_TARGET, + MenuAction.WIDGET_CLOSE, MenuAction.WIDGET_TYPE_4, MenuAction.WIDGET_TYPE_5, - MenuAction.WIDGET_TYPE_6, - MenuAction.ITEM_USE_ON_WIDGET_ITEM, - MenuAction.ITEM_USE_ON_WIDGET, + MenuAction.WIDGET_CONTINUE, + MenuAction.ITEM_USE_ON_ITEM, + MenuAction.WIDGET_USE_ON_ITEM, MenuAction.ITEM_FIRST_OPTION, MenuAction.ITEM_SECOND_OPTION, MenuAction.ITEM_THIRD_OPTION, @@ -68,7 +68,7 @@ class MouseHighlightOverlay extends Overlay MenuAction.WIDGET_FOURTH_OPTION, MenuAction.WIDGET_FIFTH_OPTION, MenuAction.EXAMINE_ITEM, - MenuAction.SPELL_CAST_ON_WIDGET, + MenuAction.WIDGET_TARGET_ON_WIDGET, MenuAction.CC_OP_LOW_PRIORITY, MenuAction.CC_OP ); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index ed736f728a..55b7c5d436 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -90,7 +90,7 @@ public class NpcIndicatorsPlugin extends Plugin private static final String UNTAG_ALL = "Un-tag-All"; private static final Set NPC_MENU_ACTIONS = ImmutableSet.of(MenuAction.NPC_FIRST_OPTION, MenuAction.NPC_SECOND_OPTION, - MenuAction.NPC_THIRD_OPTION, MenuAction.NPC_FOURTH_OPTION, MenuAction.NPC_FIFTH_OPTION, MenuAction.SPELL_CAST_ON_NPC, + MenuAction.NPC_THIRD_OPTION, MenuAction.NPC_FOURTH_OPTION, MenuAction.NPC_FIFTH_OPTION, MenuAction.WIDGET_TARGET_ON_NPC, MenuAction.ITEM_USE_ON_NPC); @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index eaa841a620..495e37283d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -42,7 +42,7 @@ import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION; import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION; import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION; import static net.runelite.api.MenuAction.RUNELITE_PLAYER; -import static net.runelite.api.MenuAction.SPELL_CAST_ON_PLAYER; +import static net.runelite.api.MenuAction.WIDGET_TARGET_ON_PLAYER; import static net.runelite.api.MenuAction.WALK; import net.runelite.api.MenuEntry; import net.runelite.api.Player; @@ -124,7 +124,7 @@ public class PlayerIndicatorsPlugin extends Plugin MenuAction type = entry.getType(); if (type == WALK - || type == SPELL_CAST_ON_PLAYER + || type == WIDGET_TARGET_ON_PLAYER || type == ITEM_USE_ON_PLAYER || type == PLAYER_FIRST_OPTION || type == PLAYER_SECOND_OPTION diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java index c5d6442ab4..4a4a457a3e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java @@ -266,8 +266,8 @@ public class WikiPlugin extends Plugin break optarget; case CANCEL: return; - case ITEM_USE_ON_WIDGET: - case SPELL_CAST_ON_GROUND_ITEM: + case WIDGET_USE_ON_ITEM: + case WIDGET_TARGET_ON_GROUND_ITEM: { type = "item"; id = itemManager.canonicalize(ev.getId()); @@ -275,7 +275,7 @@ public class WikiPlugin extends Plugin location = null; break; } - case SPELL_CAST_ON_NPC: + case WIDGET_TARGET_ON_NPC: { type = "npc"; NPC npc = client.getCachedNPCs()[ev.getId()]; @@ -285,7 +285,7 @@ public class WikiPlugin extends Plugin location = npc.getWorldLocation(); break; } - case SPELL_CAST_ON_GAME_OBJECT: + case WIDGET_TARGET_ON_GAME_OBJECT: { type = "object"; ObjectComposition lc = client.getObjectDefinition(ev.getId()); @@ -298,7 +298,7 @@ public class WikiPlugin extends Plugin location = WorldPoint.fromScene(client, ev.getParam0(), ev.getParam1(), client.getPlane()); break; } - case SPELL_CAST_ON_WIDGET: + case WIDGET_TARGET_ON_WIDGET: Widget w = getWidget(ev.getParam1(), ev.getParam0()); if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1) @@ -359,7 +359,7 @@ public class WikiPlugin extends Plugin int widgetIndex = event.getActionParam0(); int widgetID = event.getActionParam1(); - if (wikiSelected && event.getType() == MenuAction.SPELL_CAST_ON_WIDGET.getId()) + if (wikiSelected && event.getType() == MenuAction.WIDGET_TARGET_ON_WIDGET.getId()) { MenuEntry[] menuEntries = client.getMenuEntries(); Widget w = getWidget(widgetID, widgetIndex); @@ -368,7 +368,7 @@ public class WikiPlugin extends Plugin for (int ourEntry = menuEntries.length - 1;ourEntry >= 0; ourEntry--) { MenuEntry entry = menuEntries[ourEntry]; - if (entry.getType() == MenuAction.SPELL_CAST_ON_WIDGET) + if (entry.getType() == MenuAction.WIDGET_TARGET_ON_WIDGET) { int id = itemManager.canonicalize(w.getItemId()); String name = itemManager.getItemComposition(id).getName(); @@ -385,7 +385,7 @@ public class WikiPlugin extends Plugin MenuEntry[] oldEntries = menuEntries; menuEntries = Arrays.copyOf(menuEntries, menuEntries.length - 1); for (int ourEntry = oldEntries.length - 1; - ourEntry >= 2 && oldEntries[oldEntries.length - 1].getType() != MenuAction.SPELL_CAST_ON_WIDGET; + ourEntry >= 2 && oldEntries[oldEntries.length - 1].getType() != MenuAction.WIDGET_TARGET_ON_WIDGET; ourEntry--) { menuEntries[ourEntry - 1] = oldEntries[ourEntry]; From 3d089369bd41ce7a3b763498931d99c98ec9d48e Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Apr 2022 16:06:39 -0400 Subject: [PATCH 02/13] api: add selected widget api --- runelite-api/src/main/java/net/runelite/api/Client.java | 7 +++++++ .../src/main/java/net/runelite/api/MenuAction.java | 1 + 2 files changed, 8 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 278812d405..75c54b34c8 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -1901,6 +1901,13 @@ public interface Client extends OAuthApi, GameEngine */ int getSelectedItemIndex(); + /** + * Get the selected widget, such as a selected spell or selected item (eg. "Use") + * @return the selected widget + */ + @Nullable + Widget getSelectedWidget(); + /** * Returns client item composition cache */ diff --git a/runelite-api/src/main/java/net/runelite/api/MenuAction.java b/runelite-api/src/main/java/net/runelite/api/MenuAction.java index 1b636d8856..36b28d1040 100644 --- a/runelite-api/src/main/java/net/runelite/api/MenuAction.java +++ b/runelite-api/src/main/java/net/runelite/api/MenuAction.java @@ -139,6 +139,7 @@ public enum MenuAction WIDGET_TYPE_1(24), /** * Select the widget for targeting other widgets/entites etc. + * @see Client#getSelectedWidget() */ WIDGET_TARGET(25), /** From 802f8c654a6dbbd2d77d7e1fe8efeae382e35f88 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Apr 2022 16:08:39 -0400 Subject: [PATCH 03/13] api: add menuentry widget accessor --- .../src/main/java/net/runelite/api/MenuEntry.java | 10 ++++++++++ .../net/runelite/client/menus/TestMenuEntry.java | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/MenuEntry.java b/runelite-api/src/main/java/net/runelite/api/MenuEntry.java index 5cdcfe3559..c035205fb6 100644 --- a/runelite-api/src/main/java/net/runelite/api/MenuEntry.java +++ b/runelite-api/src/main/java/net/runelite/api/MenuEntry.java @@ -25,6 +25,8 @@ package net.runelite.api; import java.util.function.Consumer; +import javax.annotation.Nullable; +import net.runelite.api.widgets.Widget; /** * A menu entry in a right-click menu. @@ -92,4 +94,12 @@ public interface MenuEntry * @return */ MenuEntry onClick(Consumer callback); + + /** + * Get the widget this menu entry is on, if this is a menu entry + * with an associated widget. Such as eg, CC_OP. + * @return + */ + @Nullable + Widget getWidget(); } diff --git a/runelite-client/src/test/java/net/runelite/client/menus/TestMenuEntry.java b/runelite-client/src/test/java/net/runelite/client/menus/TestMenuEntry.java index bdcf842040..4a82a143a3 100644 --- a/runelite-client/src/test/java/net/runelite/client/menus/TestMenuEntry.java +++ b/runelite-client/src/test/java/net/runelite/client/menus/TestMenuEntry.java @@ -26,8 +26,11 @@ package net.runelite.client.menus; import java.util.function.Consumer; import lombok.EqualsAndHashCode; +import lombok.Setter; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; +import net.runelite.api.widgets.Widget; +import org.jetbrains.annotations.Nullable; @EqualsAndHashCode public class TestMenuEntry implements MenuEntry @@ -39,6 +42,8 @@ public class TestMenuEntry implements MenuEntry private int param0; private int param1; private boolean forceLeftClick; + @Setter + private Widget widget; @Override public String getOption() @@ -163,4 +168,11 @@ public class TestMenuEntry implements MenuEntry { return this; } + + @Nullable + @Override + public Widget getWidget() + { + return widget; + } } From fcb933eeefb74b68f5383bb0885578a67e16f29a Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Apr 2022 16:28:38 -0400 Subject: [PATCH 04/13] api: pass menu entry to menu clicked event and forward accessors --- .../api/events/MenuOptionClicked.java | 98 +++++++++++++------ .../client/plugins/cannon/CannonPlugin.java | 2 +- .../grounditems/GroundItemsPlugin.java | 2 +- .../cluescrolls/ClueScrollPluginTest.java | 9 +- 4 files changed, 75 insertions(+), 36 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/events/MenuOptionClicked.java b/runelite-api/src/main/java/net/runelite/api/events/MenuOptionClicked.java index 94ab334bc2..7e27376d93 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/MenuOptionClicked.java +++ b/runelite-api/src/main/java/net/runelite/api/events/MenuOptionClicked.java @@ -24,8 +24,11 @@ */ package net.runelite.api.events; -import lombok.Data; +import lombok.Getter; +import lombok.RequiredArgsConstructor; import net.runelite.api.MenuAction; +import net.runelite.api.MenuEntry; +import net.runelite.api.widgets.Widget; /** * An event where a menu option has been clicked. @@ -38,42 +41,77 @@ import net.runelite.api.MenuAction; * By default, when there is no action performed when left-clicking, * it seems that this event still triggers with the "Cancel" action. */ -@Data +@RequiredArgsConstructor public class MenuOptionClicked { /** - * Action parameter 0. Its value depends on the menuAction. + * The clicked menu entry */ - private int param0; - /** - * Action parameter 1. Its value depends on the menuAction. - */ - private int param1; - /** - * The option text added to the menu. - */ - private String menuOption; - /** - * The target of the action. - */ - private String menuTarget; - /** - * The action performed. - */ - private MenuAction menuAction; - /** - * The ID of the object, actor, or item that the interaction targets. - */ - private int id; - /** - * The selected item index at the time of the option click. - */ - private int selectedItemIndex; + private final MenuEntry menuEntry; /** * Whether or not the event has been consumed by a subscriber. */ + @Getter private boolean consumed; + /** + * Action parameter 0. Its value depends on the menuAction. + */ + public int getParam0() + { + return menuEntry.getParam0(); + } + + /** + * Action parameter 1. Its value depends on the menuAction. + */ + public int getParam1() + { + return menuEntry.getParam1(); + } + + /** + * The option text added to the menu. + */ + public String getMenuOption() + { + return menuEntry.getOption(); + } + + /** + * The target of the action. + */ + public String getMenuTarget() + { + return menuEntry.getTarget(); + } + + /** + * The action performed. + */ + public MenuAction getMenuAction() + { + return menuEntry.getType(); + } + + /** + * The ID of the object, actor, or item that the interaction targets. + */ + public int getId() + { + return menuEntry.getIdentifier(); + } + + /** + * Get the widget this menu entry is on, if this is a menu entry + * with an associated widget. Such as eg, CC_OP. + * @return + */ + public Widget getWidget() + { + return menuEntry.getWidget(); + } + /** * Marks the event as having been consumed. *

@@ -89,12 +127,12 @@ public class MenuOptionClicked @Deprecated public int getActionParam() { - return param0; + return menuEntry.getParam0(); } @Deprecated public int getWidgetId() { - return param1; + return menuEntry.getParam1(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java index 1e9282211e..13727b9ed6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java @@ -286,7 +286,7 @@ public class CannonPlugin extends Plugin // Check if cannonballs are being used on the cannon if (event.getMenuAction() == MenuAction.ITEM_USE_ON_GAME_OBJECT) { - final int idx = event.getSelectedItemIndex(); + final int idx = client.getSelectedItemIndex(); final ItemContainer items = client.getItemContainer(InventoryID.INVENTORY); if (items == null) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index 2533594e8e..7d85c4a5a2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -703,7 +703,7 @@ public class GroundItemsPlugin extends Plugin return; } - final Item clickedItem = inventory.getItem(menuOptionClicked.getSelectedItemIndex()); + final Item clickedItem = inventory.getItem(client.getSelectedItemIndex()); if (clickedItem == null) { return; diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/ClueScrollPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/ClueScrollPluginTest.java index b3ccabb37f..14dde19887 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/ClueScrollPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/ClueScrollPluginTest.java @@ -63,6 +63,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import static org.mockito.ArgumentMatchers.any; import org.mockito.Mock; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -164,10 +165,10 @@ public class ClueScrollPluginTest plugin.onGameTick(new GameTick()); // Simulate clicking on the STASH - MenuOptionClicked menuOptionClicked = new MenuOptionClicked(); - menuOptionClicked.setMenuOption("Search"); - menuOptionClicked.setMenuTarget("STASH unit (easy)"); - menuOptionClicked.setId(NullObjectID.NULL_28983); + MenuOptionClicked menuOptionClicked = mock(MenuOptionClicked.class); + when(menuOptionClicked.getMenuOption()).thenReturn("Search"); + lenient().when(menuOptionClicked.getMenuTarget()).thenReturn("STASH unit (easy)"); + when(menuOptionClicked.getId()).thenReturn(NullObjectID.NULL_28983); plugin.onMenuOptionClicked(menuOptionClicked); // Check that the STASH is stored after withdrawing From 3218fc756817a46cc2aefe20b75bef29fcf9d9ff Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Apr 2022 19:18:34 -0400 Subject: [PATCH 05/13] menu swapper: move bank swaps to client tick The underlying issue preventing this from working during client tick has been addressed --- .../MenuEntrySwapperPlugin.java | 33 +++++++++++-------- .../MenuEntrySwapperPluginTest.java | 19 ++--------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index 4ac0bec7e0..6a0e3d8fa8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -56,7 +56,6 @@ import net.runelite.api.NPC; import net.runelite.api.NPCComposition; import net.runelite.api.ObjectComposition; import net.runelite.api.events.ClientTick; -import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuOpened; import net.runelite.api.events.PostItemComposition; import net.runelite.api.widgets.WidgetID; @@ -793,15 +792,14 @@ public class MenuEntrySwapperPlugin extends Plugin } } - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) + private boolean swapBank(MenuEntry menuEntry, MenuAction type) { - // This swap needs to happen prior to drag start on click, which happens during - // widget ticking and prior to our client tick event. This is because drag start - // is what builds the context menu row which is what the eventual click will use - - final int widgetGroupId = WidgetInfo.TO_GROUP(menuEntryAdded.getActionParam1()); + if (type != MenuAction.CC_OP && type != MenuAction.CC_OP_LOW_PRIORITY) + { + return false; + } + final int widgetGroupId = WidgetInfo.TO_GROUP(menuEntry.getParam1()); final boolean isDepositBoxPlayerInventory = widgetGroupId == WidgetID.DEPOSIT_BOX_GROUP_ID; final boolean isChambersOfXericStorageUnitPlayerInventory = widgetGroupId == WidgetID.CHAMBERS_OF_XERIC_STORAGE_UNIT_INVENTORY_GROUP_ID; final boolean isGroupStoragePlayerInventory = widgetGroupId == WidgetID.GROUP_STORAGE_INVENTORY_GROUP_ID; @@ -809,9 +807,9 @@ public class MenuEntrySwapperPlugin extends Plugin // Deposit- op 1 is the current withdraw amount 1/5/10/x for deposit box interface and chambers of xeric storage unit. // Deposit- op 2 is the current withdraw amount 1/5/10/x for bank interface if (shiftModifier() && config.bankDepositShiftClick() != ShiftDepositMode.OFF - && menuEntryAdded.getType() == MenuAction.CC_OP.getId() - && menuEntryAdded.getIdentifier() == (isDepositBoxPlayerInventory || isGroupStoragePlayerInventory || isChambersOfXericStorageUnitPlayerInventory ? 1 : 2) - && (menuEntryAdded.getOption().startsWith("Deposit-") || menuEntryAdded.getOption().startsWith("Store") || menuEntryAdded.getOption().startsWith("Donate"))) + && type == MenuAction.CC_OP + && menuEntry.getIdentifier() == (isDepositBoxPlayerInventory || isGroupStoragePlayerInventory || isChambersOfXericStorageUnitPlayerInventory ? 1 : 2) + && (menuEntry.getOption().startsWith("Deposit-") || menuEntry.getOption().startsWith("Store") || menuEntry.getOption().startsWith("Donate"))) { ShiftDepositMode shiftDepositMode = config.bankDepositShiftClick(); final int opId = isDepositBoxPlayerInventory ? shiftDepositMode.getIdentifierDepositBox() @@ -820,13 +818,14 @@ public class MenuEntrySwapperPlugin extends Plugin : shiftDepositMode.getIdentifier(); final MenuAction action = opId >= 6 ? MenuAction.CC_OP_LOW_PRIORITY : MenuAction.CC_OP; bankModeSwap(action, opId); + return true; } // Swap to shift-click withdraw behavior // Deposit- op 1 is the current withdraw amount 1/5/10/x if (shiftModifier() && config.bankWithdrawShiftClick() != ShiftWithdrawMode.OFF - && menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getIdentifier() == 1 - && menuEntryAdded.getOption().startsWith("Withdraw")) + && type == MenuAction.CC_OP && menuEntry.getIdentifier() == 1 + && menuEntry.getOption().startsWith("Withdraw")) { ShiftWithdrawMode shiftWithdrawMode = config.bankWithdrawShiftClick(); final MenuAction action; @@ -842,7 +841,10 @@ public class MenuEntrySwapperPlugin extends Plugin opId = shiftWithdrawMode.getIdentifier(); } bankModeSwap(action, opId); + return true; } + + return false; } private void bankModeSwap(MenuAction entryType, int entryIdentifier) @@ -976,6 +978,11 @@ public class MenuEntrySwapperPlugin extends Plugin } } + if (swapBank(menuEntry, menuAction)) + { + return; + } + // Built-in swaps Collection swaps = this.swaps.get(option); for (Swap swap : swaps) diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java index 478bf750d4..b715902e47 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java @@ -38,7 +38,6 @@ import net.runelite.api.NPC; import net.runelite.api.NPCComposition; import net.runelite.api.ObjectComposition; import net.runelite.api.events.ClientTick; -import net.runelite.api.events.MenuEntryAdded; import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.game.ItemManager; @@ -332,14 +331,7 @@ public class MenuEntrySwapperPluginTest menu("Deposit-1", "Abyssal whip", MenuAction.CC_OP, 2), }; - menuEntrySwapperPlugin.onMenuEntryAdded(new MenuEntryAdded( - "Deposit-1", - "Abyssal whip", - MenuAction.CC_OP.getId(), - 2, - -1, - -1 - )); + menuEntrySwapperPlugin.onClientTick(new ClientTick()); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); verify(client).setMenuEntries(argumentCaptor.capture()); @@ -364,14 +356,7 @@ public class MenuEntrySwapperPluginTest menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2), }; - menuEntrySwapperPlugin.onMenuEntryAdded(new MenuEntryAdded( - "Deposit-1", - "Rune arrow", - MenuAction.CC_OP.getId(), - 2, - -1, - -1 - )); + menuEntrySwapperPlugin.onClientTick(new ClientTick()); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); verify(client).setMenuEntries(argumentCaptor.capture()); From 439ebe22e4c39a846e9a0e2d766d38d3b62fcda6 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Apr 2022 19:23:04 -0400 Subject: [PATCH 06/13] client: replace HttpUrl.parse with HttpUrl.get --- .../main/java/net/runelite/client/RuneLiteProperties.java | 2 +- .../main/java/net/runelite/client/rs/ClientLoader.java | 8 ++++---- .../main/java/net/runelite/client/util/ImageCapture.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java b/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java index 84f2c1ff7c..39181b1ae3 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java @@ -125,7 +125,7 @@ public class RuneLiteProperties public static HttpUrl getPluginHubBase() { String version = System.getProperty(PLUGINHUB_VERSION, properties.getProperty(PLUGINHUB_VERSION)); - return HttpUrl.parse(properties.get(PLUGINHUB_BASE) + "/" + version); + return HttpUrl.get(properties.get(PLUGINHUB_BASE) + "/" + version); } public static String getApiBase() diff --git a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java index defdc0637f..1966f6fbf4 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java @@ -199,7 +199,7 @@ public class ClientLoader implements Supplier private RSConfig downloadConfig() throws IOException { - HttpUrl url = HttpUrl.parse(javConfigUrl); + HttpUrl url = HttpUrl.get(javConfigUrl); IOException err = null; for (int attempt = 0; attempt < NUM_ATTEMPTS; attempt++) { @@ -249,7 +249,7 @@ public class ClientLoader implements Supplier @Nonnull private RSConfig downloadFallbackConfig() throws IOException { - RSConfig backupConfig = clientConfigLoader.fetch(HttpUrl.parse(RuneLiteProperties.getJavConfigBackup())); + RSConfig backupConfig = clientConfigLoader.fetch(HttpUrl.get(RuneLiteProperties.getJavConfigBackup())); if (Strings.isNullOrEmpty(backupConfig.getCodeBase()) || Strings.isNullOrEmpty(backupConfig.getInitialJar()) || Strings.isNullOrEmpty(backupConfig.getInitialClass())) { @@ -319,13 +319,13 @@ public class ClientLoader implements Supplier if (config.isFallback()) { // If we are using the backup config, use our own gamepack and ignore the codebase - url = HttpUrl.parse(config.getRuneLiteGamepack()); + url = HttpUrl.get(config.getRuneLiteGamepack()); } else { String codebase = config.getCodeBase(); String initialJar = config.getInitialJar(); - url = HttpUrl.parse(codebase + initialJar); + url = HttpUrl.get(codebase + initialJar); } for (int attempt = 0; ; attempt++) diff --git a/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java b/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java index 81422f259e..31afb90d22 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java +++ b/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java @@ -68,7 +68,7 @@ import okhttp3.Response; public class ImageCapture { private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.parse("https://api.imgur.com/3/image"); + private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.get("https://api.imgur.com/3/image"); private static final MediaType JSON = MediaType.parse("application/json"); private final Client client; From aeb5701d0782c3c0faf56d784f3b1f8a69f6e23b Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Apr 2022 19:28:06 -0400 Subject: [PATCH 07/13] client: replace MediaType.parse with MediaType.get --- .../src/main/java/net/runelite/client/config/ConfigClient.java | 2 +- .../client/plugins/crowdsourcing/CrowdsourcingManager.java | 2 +- .../src/main/java/net/runelite/client/util/ImageCapture.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigClient.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigClient.java index a973d3c9a8..20763b2cce 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigClient.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigClient.java @@ -50,7 +50,7 @@ import okhttp3.Response; @Slf4j public class ConfigClient { - private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain"); + private static final MediaType TEXT_PLAIN = MediaType.get("text/plain"); private static final Gson GSON = RuneLiteAPI.GSON; private final OkHttpClient client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/CrowdsourcingManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/CrowdsourcingManager.java index 09d737c10f..143f5bcc69 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/CrowdsourcingManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/CrowdsourcingManager.java @@ -45,7 +45,7 @@ import okhttp3.Response; public class CrowdsourcingManager { private static final String CROWDSOURCING_BASE = "https://crowdsource.runescape.wiki/runelite"; - private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + private static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); @Inject private OkHttpClient okHttpClient; diff --git a/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java b/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java index 31afb90d22..dff5c34163 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java +++ b/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java @@ -69,7 +69,7 @@ public class ImageCapture { private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.get("https://api.imgur.com/3/image"); - private static final MediaType JSON = MediaType.parse("application/json"); + private static final MediaType JSON = MediaType.get("application/json"); private final Client client; private final Notifier notifier; From aca22f13c06235fdd954c5de33df83f249924b5f Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 17 Apr 2022 23:30:57 -0400 Subject: [PATCH 08/13] fatal error dialog: work with substance laf Changing the laf from substance to system breaks the client the next time it paints --- .../runelite/client/ui/FatalErrorDialog.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/FatalErrorDialog.java b/runelite-client/src/main/java/net/runelite/client/ui/FatalErrorDialog.java index 3ad4373a9a..221ab8d89b 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/FatalErrorDialog.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/FatalErrorDialog.java @@ -27,7 +27,6 @@ package net.runelite.client.ui; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.event.WindowAdapter; @@ -45,7 +44,6 @@ import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; -import javax.swing.UIManager; import javax.swing.border.EmptyBorder; import lombok.extern.slf4j.Slf4j; import net.runelite.client.RuneLite; @@ -53,6 +51,7 @@ import net.runelite.client.RuneLiteProperties; import net.runelite.client.util.ImageUtil; import net.runelite.client.util.LinkBrowser; import net.runelite.client.util.VerificationException; +import org.pushingpixels.substance.internal.SubstanceSynapse; @Slf4j public class FatalErrorDialog extends JDialog @@ -70,16 +69,6 @@ public class FatalErrorDialog extends JDialog throw new IllegalStateException("Fatal error during fatal error: " + message); } - try - { - UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - } - catch (Exception e) - { - } - - UIManager.put("Button.select", ColorScheme.DARKER_GRAY_COLOR); - try { BufferedImage logo = ImageUtil.loadImageResource(FatalErrorDialog.class, "runelite_transparent.png"); @@ -108,8 +97,9 @@ public class FatalErrorDialog extends JDialog setTitle("Fatal error starting RuneLite"); setLayout(new BorderLayout()); - Container pane = getContentPane(); + JPanel pane = (JPanel) getContentPane(); pane.setBackground(ColorScheme.DARKER_GRAY_COLOR); + pane.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0); JPanel leftPane = new JPanel(); leftPane.setBackground(ColorScheme.DARKER_GRAY_COLOR); @@ -130,6 +120,7 @@ public class FatalErrorDialog extends JDialog textArea.setWrapStyleWord(true); textArea.setBorder(new EmptyBorder(10, 10, 10, 10)); textArea.setEditable(false); + textArea.setOpaque(false); leftPane.add(textArea, BorderLayout.CENTER); pane.add(leftPane, BorderLayout.CENTER); From ba1ab4cde24098a64c2bb7465e79510b29c848d6 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Mon, 18 Apr 2022 20:57:35 -0600 Subject: [PATCH 09/13] rl-client: pin new Plugin Hub certificate --- .../externalplugins/externalplugins.crt | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/runelite-client/src/main/resources/net/runelite/client/externalplugins/externalplugins.crt b/runelite-client/src/main/resources/net/runelite/client/externalplugins/externalplugins.crt index 2ba1550b51..b47c67505f 100644 --- a/runelite-client/src/main/resources/net/runelite/client/externalplugins/externalplugins.crt +++ b/runelite-client/src/main/resources/net/runelite/client/externalplugins/externalplugins.crt @@ -1,19 +1,30 @@ -----BEGIN CERTIFICATE----- -MIIDDDCCAfSgAwIBAgIJAK8uBanmNQZaMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV -BAMMEHJ1bmVsaXRlLXBsdWdpbnMwHhcNMTkxMjEyMjEwNzUxWhcNMjUxMjEwMjEw -NzUxWjAbMRkwFwYDVQQDDBBydW5lbGl0ZS1wbHVnaW5zMIIBIjANBgkqhkiG9w0B -AQEFAAOCAQ8AMIIBCgKCAQEApu11OVANSU+pHaXRxB7fIZapucJ6BT46neicEixs -NVPuK/QRVjO/G8F++MXFD/tlZUOEDllDN8uaHBIVwxilqEVYL7oX65Esl7qqC1TZ -WGdjiMyYoK3CXWEWB4w+CdB31T7JG2HqH45ZsVs+U9OVWBkNkL5nNQNPOmZFd+3A -yCb9nGlO7SxduiHpwh3CV19jY47y8tevyo5qpaBuQeWtu3vbpeer0kbDarwD3xoF -yUMPRK518gxRUSmOpsSG5viQ731mKVCUUfIXz91d3s+kJYAjORHS4zJe9s+1dljp -oLYNLkaP6m3CmNtC84OxkmognvZTNMbiQ3GQm/BK4sdjPQIDAQABo1MwUTAdBgNV -HQ4EFgQUxrkiRXNd0OHPMkqgl9UgV1//OuQwHwYDVR0jBBgwFoAUxrkiRXNd0OHP -Mkqgl9UgV1//OuQwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEA -StPyblz3aqOM5z2KqHX1B7Z3Q8B58g55YSefpcfwWEc6LT4HCztszcZDteWpV3W2 -ERfemkGKgsDhQ0qkzIt7tS5eNN3PPj7RZZm7vl5HquQ1vC/33ri/Z3CEKzbW7knt -i1iEpx8E9DKb9J9DjdKwNxSomOyCOFUt9YoQJs80xc1mwPDd6aWR3xwvnEUimkm+ -Dbj7HMOXLeyN810wkeWcT8nC5GhxH3ZAmVExBHsaIOB876RntzshBehjY8s8JQhw -R+fT1e8EhYMM9ylYDk1KIWFWrAujjU04lS9tXZ5C2e7fr9R953XN6Y0PNM/taNTU -GzwGroJZI02V+1ADO14rRA== ------END CERTIFICATE----- \ No newline at end of file +MIIFFTCCAv2gAwIBAgIUHZQhtTfY+I19Gz+JKYfvT6IM55QwDQYJKoZIhvcNAQEL +BQAwGjEYMBYGA1UEAwwPcnVuZWxpdGUtcGx1Z2luMB4XDTIyMDQxOTAxMjIzNFoX +DTMyMDQxNjAxMjIzNFowGjEYMBYGA1UEAwwPcnVuZWxpdGUtcGx1Z2luMIICIjAN +BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw4Dkg5UBgD3X8UtChrnxCYaoe68J +uuY+lESNROWb27EAEcLHo/DBbW0q0n6zL4vKjHs4Acsq+Z9kblyXN572851b8hur +5CbHq0Uc4r1dUiMCYHjSJ/BkvGKMPs6Yo1CmzXqc9IPV/zoHC+yJH7R6hmIkLWu4 +CytXvmkIGEvOJoJ+LZyWcifBzX7Aua6IuWHHhTAxEcAxkrBFImfC9wgWD8sL/r2F +Xyzo3jkv1LognWFbuMGQYgG+PvO8Ia+p8cko9YZnH3+SQmtr+VPbLD+VOAyDxhH1 +jX46SsSoB2sIIfCB3oNTERM1Wmy0xL5GYBj8PWOanWQY+rKku07SS8DBirkWRTVB +lboNt60Di6FhrPnxTGA8DcxdYAJVZEQOS6ed540Bl40JMEdeMG66PGRDJJlIMyrc +3xa8Z6XoKMV0QCv5ETBQwnED3lXsViFDoeC6wCww1ZjOFMwHfk5O6N5CsyJOEoGC +Y9LiUwzLkf2po6LGLRrUsiDf/a+nsMUam5Zhmdt6a77wii+cH7oaAAieLk11u1qr +Gc43gJtrzBY0thF5QiGtWlGHo7VY32Zlf9GnHkFSTTMdQX66VkWan6y080gr+HVn +aP1oN9cxBrfWc0XMBGp+uZf60p7D9gbPQG0bJUF7GDtgcZt+b8NK9u8hnJZVi8oX +AmLfUvCZ4Uv/sjMCAwEAAaNTMFEwHQYDVR0OBBYEFEFHyDZIF4aE3o+ChP3/Y6eO +VsOQMB8GA1UdIwQYMBaAFEFHyDZIF4aE3o+ChP3/Y6eOVsOQMA8GA1UdEwEB/wQF +MAMBAf8wDQYJKoZIhvcNAQELBQADggIBAH3Wm63s7ifC7cIeBLgM4LJxU9Qx1YA4 +7U2WEoChoeDj4iBs5cAKCBXU9hbw2/Ij8JqYG1sjZGNZjdqzYtjh36K4j+vgTmK5 +vufXlzC+MUwWt853QIrgWs4c2HO4HnQgsss7UJm3aofVeqEVH9MeHcmKiL/3uQFT +DiR31+MxLaQZw0JcmVMGR0WU6eXyi4lkZL82BGwponjaOgB4oxrHRqqrV7I93Y/v +GRiRwfcgP0QXORdfDmhtzaY6ay4TX1qzcXH/a78EGk3Bzgg20kh+6r8YRoBpbtM4 +O4hZKhKtwGDDRHrVHy5gVh3hjAUdb2kdlxjxPocnkIiOWCrX2P5GA5NF6+deRE+B +NZO+3VAD40meNlaoVqSnXW2hmeqShWEclNkdyTieSLFTLpsPGIlC7+NYAgc6j9Jc +oFdcmdChavHv7UVbgg8Kp1ypfQLThNG9gWf+PByqRrEcCSKG3J1JrKwh8tqOXkNh +N5o3ON56H1WFPwkXji3amhkNCVHq13qgCXtPXTRSVcFTtPVrCKB5DSFqHErb73/5 +WDkj4GYAVeL0+znFYktj/cxD0J8QRgNCVZeFCmxWpuN1WekHzy3C2TjO4We/x1yP +9HGVWLvJL8U8tgEO3c3g1OH9Z5SwHhgjNFw1VMfpKngFWp96o/OAJTX9K++5gKwm +Y5Hm2HkwTow+ +-----END CERTIFICATE----- From eb0bbc6426a24e48aef74073d8f97011e74f615f Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 19 Apr 2022 18:58:50 -0400 Subject: [PATCH 10/13] external plugin client: use verificationexception for security exceptions --- .../client/externalplugins/ExternalPluginClient.java | 2 +- .../java/net/runelite/client/util/VerificationException.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginClient.java b/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginClient.java index 6bea4781c3..d2211bda38 100644 --- a/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginClient.java +++ b/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginClient.java @@ -111,7 +111,7 @@ public class ExternalPluginClient } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { - throw new RuntimeException(e); + throw new VerificationException(e); } } diff --git a/runelite-client/src/main/java/net/runelite/client/util/VerificationException.java b/runelite-client/src/main/java/net/runelite/client/util/VerificationException.java index 2f6f1f5dee..2f28a0378c 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/VerificationException.java +++ b/runelite-client/src/main/java/net/runelite/client/util/VerificationException.java @@ -31,6 +31,11 @@ public class VerificationException extends Exception super(message); } + public VerificationException(Throwable cause) + { + super(cause); + } + public VerificationException(String message, Throwable cause) { super(message, cause); From c683e41c018e8f522a2f03ec8c6650d105aa6a57 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 18 Apr 2022 20:14:53 -0400 Subject: [PATCH 11/13] api: add item op menu api --- .../main/java/net/runelite/api/MenuEntry.java | 20 +++++++++++++ .../api/events/MenuOptionClicked.java | 29 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/MenuEntry.java b/runelite-api/src/main/java/net/runelite/api/MenuEntry.java index c035205fb6..bd33855448 100644 --- a/runelite-api/src/main/java/net/runelite/api/MenuEntry.java +++ b/runelite-api/src/main/java/net/runelite/api/MenuEntry.java @@ -95,6 +95,26 @@ public interface MenuEntry */ MenuEntry onClick(Consumer callback); + /** + * Test if this menu entry is an item op. "Use" and "Examine" are not considered item ops. + * @return + */ + boolean isItemOp(); + + /** + * If this menu entry is an item op, get the item op id + * @return 1-5 + */ + int getItemOp(); + + /** + * If this menu entry is an item op, get the item id + * @return + * @see ItemID + * @see NullItemID + */ + int getItemId(); + /** * Get the widget this menu entry is on, if this is a menu entry * with an associated widget. Such as eg, CC_OP. diff --git a/runelite-api/src/main/java/net/runelite/api/events/MenuOptionClicked.java b/runelite-api/src/main/java/net/runelite/api/events/MenuOptionClicked.java index 7e27376d93..b2d1defa8b 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/MenuOptionClicked.java +++ b/runelite-api/src/main/java/net/runelite/api/events/MenuOptionClicked.java @@ -102,6 +102,35 @@ public class MenuOptionClicked return menuEntry.getIdentifier(); } + /** + * Test if this menu entry is an item op. "Use" and "Examine" are not considered item ops. + * @return + */ + public boolean isItemOp() + { + return menuEntry.isItemOp(); + } + + /** + * If this menu entry is an item op, get the item op id + * @return 1-5 + */ + public int getItemOp() + { + return menuEntry.getItemOp(); + } + + /** + * If this menu entry is an item op, get the item id + * @return + * @see net.runelite.api.ItemID + * @see net.runelite.api.NullItemID + */ + public int getItemId() + { + return menuEntry.getItemId(); + } + /** * Get the widget this menu entry is on, if this is a menu entry * with an associated widget. Such as eg, CC_OP. From a6f955ac8767de821fcc3dbc2ad9f9f7736e87fc Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 18 Apr 2022 20:15:06 -0400 Subject: [PATCH 12/13] client: update for if3 inventory --- .../client/plugins/cannon/CannonPlugin.java | 18 ++-- .../plugins/cluescrolls/ClueScrollPlugin.java | 10 +- .../cooking/CrowdsourcingCooking.java | 4 +- .../crowdsourcing/zmi/CrowdsourcingZMI.java | 6 +- .../grounditems/GroundItemsPlugin.java | 24 +---- .../InteractHighlightPlugin.java | 10 ++ .../inventorytags/InventoryTagsPlugin.java | 63 ++++++------- .../plugins/itemprices/ItemPricesOverlay.java | 74 +++++++++------ .../loottracker/LootTrackerPlugin.java | 22 ++--- .../MenuEntrySwapperPlugin.java | 92 ++++++++++--------- .../runelite/client/menus/TestMenuEntry.java | 22 +++++ 11 files changed, 191 insertions(+), 154 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java index 13727b9ed6..2c69cef83d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java @@ -34,6 +34,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import net.runelite.api.AnimationID; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -58,6 +59,8 @@ import net.runelite.api.events.GameTick; import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.events.ProjectileMoved; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.Notifier; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; @@ -74,6 +77,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; description = "Show information about cannon placement and/or amount of cannonballs", tags = {"combat", "notifications", "ranged", "overlay"} ) +@Slf4j public class CannonPlugin extends Plugin { private static final Pattern NUMBER_PATTERN = Pattern.compile("([0-9]+)"); @@ -284,16 +288,11 @@ public class CannonPlugin extends Plugin } // Check if cannonballs are being used on the cannon - if (event.getMenuAction() == MenuAction.ITEM_USE_ON_GAME_OBJECT) + if (event.getMenuAction() == MenuAction.WIDGET_TARGET_ON_GAME_OBJECT && client.getSelectedWidget().getId() == WidgetInfo.INVENTORY.getId()) { - final int idx = client.getSelectedItemIndex(); - final ItemContainer items = client.getItemContainer(InventoryID.INVENTORY); - if (items == null) - { - return; - } - final Item item = items.getItem(idx); - if (item == null || (item.getId() != ItemID.CANNONBALL && item.getId() != ItemID.GRANITE_CANNONBALL)) + final Widget selected = client.getSelectedWidget(); + final int itemId = selected.getItemId(); + if (itemId != ItemID.CANNONBALL && itemId != ItemID.GRANITE_CANNONBALL) { return; } @@ -306,6 +305,7 @@ public class CannonPlugin extends Plugin // Store the click location as a WorldPoint to avoid issues with scene loads clickedCannonLocation = WorldPoint.fromScene(client, event.getParam0(), event.getParam1(), client.getPlane()); + log.debug("Updated cannon location: {}", clickedCannonLocation); } @Subscribe diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index 3114136231..7df023ef60 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -325,14 +325,8 @@ public class ClueScrollPlugin extends Plugin return; } - final boolean itemClicked = event.getMenuAction() == MenuAction.ITEM_FIRST_OPTION - || event.getMenuAction() == MenuAction.ITEM_SECOND_OPTION - || event.getMenuAction() == MenuAction.ITEM_THIRD_OPTION - || event.getMenuAction() == MenuAction.ITEM_FOURTH_OPTION - || event.getMenuAction() == MenuAction.ITEM_FIFTH_OPTION; - final boolean isXMarksTheSpotOrb = event.getId() == ItemID.MYSTERIOUS_ORB_23069; - - if (itemClicked && (isXMarksTheSpotOrb || event.getMenuOption().equals("Read"))) + final boolean isXMarksTheSpotOrb = event.getItemId() == ItemID.MYSTERIOUS_ORB_23069; + if (isXMarksTheSpotOrb || event.getMenuOption().equals("Read")) { final ItemComposition itemComposition = itemManager.getItemComposition(event.getId()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/cooking/CrowdsourcingCooking.java b/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/cooking/CrowdsourcingCooking.java index f461bdee5b..2d5e509958 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/cooking/CrowdsourcingCooking.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/cooking/CrowdsourcingCooking.java @@ -37,6 +37,7 @@ import net.runelite.api.Skill; import net.runelite.api.Varbits; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.MenuOptionClicked; +import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.crowdsourcing.CrowdsourcingManager; @@ -114,7 +115,8 @@ public class CrowdsourcingCooking || action == MenuAction.GAME_OBJECT_SECOND_OPTION || action == MenuAction.GAME_OBJECT_THIRD_OPTION || action == MenuAction.GAME_OBJECT_FOURTH_OPTION - || action == MenuAction.GAME_OBJECT_FIFTH_OPTION) + || action == MenuAction.GAME_OBJECT_FIFTH_OPTION + || action == MenuAction.WIDGET_TARGET_ON_GAME_OBJECT && client.getSelectedWidget().getId() == WidgetInfo.INVENTORY.getId()) { lastGameObjectClicked = menuOptionClicked.getId(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/zmi/CrowdsourcingZMI.java b/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/zmi/CrowdsourcingZMI.java index d001d03555..b83a4ca8dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/zmi/CrowdsourcingZMI.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/zmi/CrowdsourcingZMI.java @@ -77,7 +77,11 @@ public class CrowdsourcingZMI public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) { MenuAction action = menuOptionClicked.getMenuAction(); - + if (menuOptionClicked.isItemOp()) + { + illegalActionTick = client.getTickCount(); + return; + } switch (action) { case ITEM_FIRST_OPTION: diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index 7d85c4a5a2..f0dd02dd71 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -54,10 +54,7 @@ import lombok.Setter; import lombok.Value; import net.runelite.api.Client; import net.runelite.api.GameState; -import net.runelite.api.InventoryID; -import net.runelite.api.Item; import net.runelite.api.ItemComposition; -import net.runelite.api.ItemContainer; import net.runelite.api.ItemID; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; @@ -72,6 +69,7 @@ import net.runelite.api.events.ItemQuantityChanged; import net.runelite.api.events.ItemSpawned; import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuOptionClicked; +import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.Notifier; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; @@ -688,28 +686,16 @@ public class GroundItemsPlugin extends Plugin @Subscribe public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked) { - if (menuOptionClicked.getMenuAction() == MenuAction.ITEM_FIFTH_OPTION) + if (menuOptionClicked.isItemOp() && menuOptionClicked.getMenuOption().equals("Drop")) { - int itemId = menuOptionClicked.getId(); + int itemId = menuOptionClicked.getItemId(); // Keep a queue of recently dropped items to better detect // item spawns that are drops droppedItemQueue.add(itemId); } - else if (menuOptionClicked.getMenuAction() == MenuAction.ITEM_USE_ON_GAME_OBJECT) + else if (menuOptionClicked.getMenuAction() == MenuAction.WIDGET_TARGET_ON_GAME_OBJECT && client.getSelectedWidget().getId() == WidgetInfo.INVENTORY.getId()) { - final ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); - if (inventory == null) - { - return; - } - - final Item clickedItem = inventory.getItem(client.getSelectedItemIndex()); - if (clickedItem == null) - { - return; - } - - lastUsedItem = clickedItem.getId(); + lastUsedItem = client.getSelectedWidget().getItemId(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightPlugin.java index 1028a8bef7..f2a5b84e2b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interacthighlight/InteractHighlightPlugin.java @@ -176,8 +176,11 @@ public class InteractHighlightPlugin extends Plugin // Any menu click which clears an interaction case WALK: case ITEM_USE: + case WIDGET_TARGET_ON_WIDGET: case ITEM_USE_ON_GROUND_ITEM: + case WIDGET_TARGET_ON_GROUND_ITEM: case ITEM_USE_ON_PLAYER: + case WIDGET_TARGET_ON_PLAYER: case ITEM_FIRST_OPTION: case ITEM_SECOND_OPTION: case ITEM_THIRD_OPTION: @@ -190,6 +193,13 @@ public class InteractHighlightPlugin extends Plugin case GROUND_ITEM_FIFTH_OPTION: interactedObject = null; interactedNpc = null; + break; + default: + if (menuOptionClicked.isItemOp()) + { + interactedObject = null; + interactedNpc = null; + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java index d588ed42aa..2ea53fa68f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java @@ -164,42 +164,43 @@ public class InventoryTagsPlugin extends Plugin return; } - final int widgetId = firstEntry.getParam1(); - - // Inventory item menu - if (widgetId == WidgetInfo.INVENTORY.getId()) + final int itemId; + if (firstEntry.getType() == MenuAction.WIDGET_TARGET && firstEntry.getWidget().getId() == WidgetInfo.INVENTORY.getId()) { - int itemId = firstEntry.getIdentifier(); + itemId = firstEntry.getWidget().getItemId(); + } + else if (firstEntry.isItemOp()) + { + itemId = firstEntry.getItemId(); + } + else + { + return; + } - if (itemId == -1) - { - return; - } + // Set menu to only be Cancel + client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), 1)); - // Set menu to only be Cancel - client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), 1)); + for (final String groupName : GROUPS) + { + final String group = getTag(itemId); + final Color color = getGroupNameColor(groupName); - for (final String groupName : GROUPS) - { - final String group = getTag(itemId); - final Color color = getGroupNameColor(groupName); - - client.createMenuEntry(-1) - .setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET) - .setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE))) - .setType(MenuAction.RUNELITE) - .onClick(e -> + client.createMenuEntry(-1) + .setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET) + .setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE))) + .setType(MenuAction.RUNELITE) + .onClick(e -> + { + if (e.getOption().equals(MENU_SET)) { - if (e.getOption().equals(MENU_SET)) - { - setTag(itemId, groupName); - } - else - { - unsetTag(itemId); - } - }); - } + setTag(itemId, groupName); + } + else + { + unsetTag(itemId); + } + }); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java index 0b62f029fd..cd919cd89f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java @@ -98,11 +98,20 @@ class ItemPricesOverlay extends Overlay // Tooltip action type handling switch (action) { + case WIDGET_TARGET_ON_WIDGET: + // Check target widget is the inventory + if (menuEntry.getWidget().getId() != WidgetInfo.INVENTORY.getId()) + { + break; + } + // FALLTHROUGH case WIDGET_USE_ON_ITEM: + // Require showWhileAlching and Cast High Level Alchemy if (!config.showWhileAlching() || !isAlching) { break; } + // FALLTHROUGH case CC_OP: case ITEM_USE: case ITEM_FIRST_OPTION: @@ -110,38 +119,49 @@ class ItemPricesOverlay extends Overlay case ITEM_THIRD_OPTION: case ITEM_FOURTH_OPTION: case ITEM_FIFTH_OPTION: - // Item tooltip values - switch (groupId) - { - case WidgetID.EXPLORERS_RING_ALCH_GROUP_ID: - if (!config.showWhileAlching()) - { - return null; - } - case WidgetID.INVENTORY_GROUP_ID: - case WidgetID.POH_TREASURE_CHEST_INVENTORY_GROUP_ID: - if (config.hideInventory() && !(config.showWhileAlching() && isAlching)) - { - return null; - } - // intentional fallthrough - case WidgetID.BANK_GROUP_ID: - case WidgetID.BANK_INVENTORY_GROUP_ID: - case WidgetID.SEED_VAULT_GROUP_ID: - case WidgetID.SEED_VAULT_INVENTORY_GROUP_ID: - // Make tooltip - final String text = makeValueTooltip(menuEntry); - if (text != null) - { - tooltipManager.add(new Tooltip(ColorUtil.prependColorTag(text, new Color(238, 238, 238)))); - } - break; - } + addTooltip(menuEntry, isAlching, groupId); break; + case WIDGET_TARGET: + // Check that this is the inventory + if (menuEntry.getWidget().getId() == WidgetInfo.INVENTORY.getId()) + { + addTooltip(menuEntry, isAlching, groupId); + } } + return null; } + private void addTooltip(MenuEntry menuEntry, boolean isAlching, int groupId) + { + // Item tooltip values + switch (groupId) + { + case WidgetID.EXPLORERS_RING_ALCH_GROUP_ID: + if (!config.showWhileAlching()) + { + return; + } + case WidgetID.INVENTORY_GROUP_ID: + case WidgetID.POH_TREASURE_CHEST_INVENTORY_GROUP_ID: + if (config.hideInventory() && (!config.showWhileAlching() || !isAlching)) + { + return; + } + // FALLTHROUGH + case WidgetID.BANK_GROUP_ID: + case WidgetID.BANK_INVENTORY_GROUP_ID: + case WidgetID.SEED_VAULT_GROUP_ID: + case WidgetID.SEED_VAULT_INVENTORY_GROUP_ID: + // Make tooltip + final String text = makeValueTooltip(menuEntry); + if (text != null) + { + tooltipManager.add(new Tooltip(ColorUtil.prependColorTag(text, new Color(238, 238, 238)))); + } + } + } + private String makeValueTooltip(MenuEntry menuEntry) { // Disabling both disables all value tooltips diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index 5d570d52ff..0ad15a2493 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -971,19 +971,19 @@ public class LootTrackerPlugin extends Plugin { onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, SHADE_CHEST_OBJECTS.get(event.getId()))); } - else if (isItemOp(event.getMenuAction())) + else if (event.isItemOp()) { - if (event.getMenuOption().equals("Take") && event.getId() == ItemID.SEED_PACK) + if (event.getMenuOption().equals("Take") && event.getItemId() == ItemID.SEED_PACK) { onInvChange(collectInvItems(LootRecordType.EVENT, SEEDPACK_EVENT)); } - else if (event.getMenuOption().equals("Search") && BIRDNEST_IDS.contains(event.getId())) + else if (event.getMenuOption().equals("Search") && BIRDNEST_IDS.contains(event.getItemId())) { onInvChange(collectInvItems(LootRecordType.EVENT, BIRDNEST_EVENT)); } else if (event.getMenuOption().equals("Open")) { - switch (event.getId()) + switch (event.getItemId()) { case ItemID.CASKET: onInvChange(collectInvItems(LootRecordType.EVENT, CASKET_EVENT)); @@ -1004,7 +1004,7 @@ public class LootTrackerPlugin extends Plugin case ItemID.SIMPLE_LOCKBOX_25647: case ItemID.ELABORATE_LOCKBOX_25649: case ItemID.ORNATE_LOCKBOX_25651: - onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, itemManager.getItemComposition(event.getId()).getName())); + onInvChange(collectInvAndGroundItems(LootRecordType.EVENT, itemManager.getItemComposition(event.getItemId()).getName())); break; case ItemID.SUPPLY_CRATE_24884: onInvChange(collectInvItems(LootRecordType.EVENT, MAHOGANY_CRATE_EVENT, client.getBoostedSkillLevel(Skill.CONSTRUCTION))); @@ -1014,14 +1014,14 @@ public class LootTrackerPlugin extends Plugin break; } } - else if (event.getMenuOption().equals("Loot") && IMPLING_JARS.contains(event.getId())) + else if (event.getMenuOption().equals("Loot") && IMPLING_JARS.contains(event.getItemId())) { onInvChange(((invItems, groundItems, removedItems) -> { - int cnt = removedItems.count(event.getId()); + int cnt = removedItems.count(event.getItemId()); if (cnt > 0) { - String name = itemManager.getItemComposition(event.getId()).getName(); + String name = itemManager.getItemComposition(event.getItemId()).getName(); addLoot(name, -1, LootRecordType.EVENT, null, invItems, cnt); } })); @@ -1038,12 +1038,6 @@ public class LootTrackerPlugin extends Plugin } } - private static boolean isItemOp(MenuAction menuAction) - { - final int id = menuAction.getId(); - return id >= MenuAction.ITEM_FIRST_OPTION.getId() && id <= MenuAction.ITEM_FIFTH_OPTION.getId(); - } - private static boolean isNPCOp(MenuAction menuAction) { final int id = menuAction.getId(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index 6a0e3d8fa8..09127ee939 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -132,15 +132,6 @@ public class MenuEntrySwapperPlugin extends Plugin private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_LC = new WidgetMenuOption(SAVE, LEFT_CLICK_MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB); - private static final Set ITEM_MENU_TYPES = ImmutableSet.of( - MenuAction.ITEM_FIRST_OPTION, - MenuAction.ITEM_SECOND_OPTION, - MenuAction.ITEM_THIRD_OPTION, - MenuAction.ITEM_FOURTH_OPTION, - MenuAction.ITEM_FIFTH_OPTION, - MenuAction.ITEM_USE - ); - private static final List NPC_MENU_TYPES = ImmutableList.of( MenuAction.NPC_FIRST_OPTION, MenuAction.NPC_SECOND_OPTION, @@ -536,25 +527,27 @@ public class MenuEntrySwapperPlugin extends Plugin return; } - MenuEntry firstEntry = event.getFirstEntry(); + final MenuEntry firstEntry = event.getFirstEntry(); if (firstEntry == null) { return; } - int widgetId = firstEntry.getParam1(); - if (widgetId != WidgetInfo.INVENTORY.getId()) + final int itemId; + if (firstEntry.getType() == MenuAction.WIDGET_TARGET && firstEntry.getWidget().getId() == WidgetInfo.INVENTORY.getId()) + { + itemId = firstEntry.getWidget().getItemId(); + } + else if (firstEntry.isItemOp()) + { + itemId = firstEntry.getItemId(); + } + else { return; } - int itemId = firstEntry.getIdentifier(); - if (itemId == -1) - { - return; - } - - MenuAction activeAction = null; + int activeOp = 0; final ItemComposition itemComposition = itemManager.getItemComposition(itemId); if (configuringShiftClick) @@ -565,7 +558,7 @@ public class MenuEntrySwapperPlugin extends Plugin if (shiftClickActionIndex >= 0) { - activeAction = MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + shiftClickActionIndex); + activeOp = 1 + shiftClickActionIndex; } else { @@ -573,7 +566,7 @@ public class MenuEntrySwapperPlugin extends Plugin Integer config = getItemSwapConfig(true, itemId); if (config != null && config == -1) { - activeAction = MenuAction.ITEM_USE; + activeOp = -1; } } } @@ -583,9 +576,9 @@ public class MenuEntrySwapperPlugin extends Plugin Integer config = getItemSwapConfig(false, itemId); if (config != null) { - activeAction = config >= 0 - ? MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + config) - : MenuAction.ITEM_USE; + activeOp = config >= 0 + ? 1 + config + : -1; } } @@ -593,20 +586,31 @@ public class MenuEntrySwapperPlugin extends Plugin for (MenuEntry entry : entries) { - final MenuAction menuAction = entry.getType(); - - if (ITEM_MENU_TYPES.contains(menuAction) && entry.getIdentifier() == itemId) + if (entry.getType() == MenuAction.WIDGET_TARGET && entry.getWidget().getId() == WidgetInfo.INVENTORY.getId() && entry.getWidget().getItemId() == itemId) { entry.setType(MenuAction.RUNELITE); entry.onClick(e -> { - int index = menuAction == MenuAction.ITEM_USE - ? -1 - : menuAction.getId() - MenuAction.ITEM_FIRST_OPTION.getId(); - setItemSwapConfig(configuringShiftClick, itemId, index); + log.debug("Set {} item swap for {} to USE", configuringShiftClick ? "shift" : "left", itemId); + setItemSwapConfig(configuringShiftClick, itemId, -1); }); - if (activeAction == menuAction) + if (activeOp == -1) + { + entry.setOption("* " + entry.getOption()); + } + } + else if (entry.isItemOp() && entry.getItemId() == itemId) + { + final int itemOp = entry.getItemOp(); + entry.setType(MenuAction.RUNELITE); + entry.onClick(e -> + { + log.debug("Set {} item swap config for {} to {}", configuringShiftClick ? "shift" : "left", itemId, itemOp - 1); + setItemSwapConfig(configuringShiftClick, itemId, itemOp - 1); + }); + + if (itemOp == activeOp) { entry.setOption("* " + entry.getOption()); } @@ -885,19 +889,15 @@ public class MenuEntrySwapperPlugin extends Plugin return; } - final boolean itemOp = menuAction == MenuAction.ITEM_FIRST_OPTION - || menuAction == MenuAction.ITEM_SECOND_OPTION - || menuAction == MenuAction.ITEM_THIRD_OPTION - || menuAction == MenuAction.ITEM_FOURTH_OPTION - || menuAction == MenuAction.ITEM_FIFTH_OPTION - || menuAction == MenuAction.ITEM_USE; + final boolean itemOp = menuEntry.isItemOp(); + // Custom shift-click item swap if (shiftModifier() && itemOp) { // Special case use shift click due to items not actually containing a "Use" option, making // the client unable to perform the swap itself. if (config.shiftClickCustomization() && !option.equals("use")) { - Integer customOption = getItemSwapConfig(true, eventId); + Integer customOption = getItemSwapConfig(true, menuEntry.getItemId()); if (customOption != null && customOption == -1) { @@ -913,14 +913,18 @@ public class MenuEntrySwapperPlugin extends Plugin // Custom left-click item swap if (itemOp) { - Integer swapIndex = getItemSwapConfig(false, eventId); + Integer swapIndex = getItemSwapConfig(false, menuEntry.getItemId()); if (swapIndex != null) { - MenuAction swapAction = swapIndex >= 0 - ? MenuAction.of(MenuAction.ITEM_FIRST_OPTION.getId() + swapIndex) - : MenuAction.ITEM_USE; + final int swapAction = swapIndex >= 0 + ? 1 + swapIndex + : -1; - if (menuAction == swapAction) + if (swapAction == -1) + { + swap(menuEntries, "use", target, index, true); + } + else if (swapAction == menuEntry.getItemOp()) { swap(optionIndexes, menuEntries, index, menuEntries.length - 1); } diff --git a/runelite-client/src/test/java/net/runelite/client/menus/TestMenuEntry.java b/runelite-client/src/test/java/net/runelite/client/menus/TestMenuEntry.java index 4a82a143a3..688de43236 100644 --- a/runelite-client/src/test/java/net/runelite/client/menus/TestMenuEntry.java +++ b/runelite-client/src/test/java/net/runelite/client/menus/TestMenuEntry.java @@ -43,6 +43,10 @@ public class TestMenuEntry implements MenuEntry private int param1; private boolean forceLeftClick; @Setter + private int itemOp = -1; + @Setter + private int itemId = -1; + @Setter private Widget widget; @Override @@ -169,6 +173,24 @@ public class TestMenuEntry implements MenuEntry return this; } + @Override + public boolean isItemOp() + { + return itemOp != -1; + } + + @Override + public int getItemOp() + { + return itemOp; + } + + @Override + public int getItemId() + { + return itemId; + } + @Nullable @Override public Widget getWidget() From 3015dad5344b838cd16678fd05b84ba580a287f2 Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Tue, 19 Apr 2022 08:28:37 -0600 Subject: [PATCH 13/13] Update Scripts to 2022-4-20 --- .../src/main/scripts/CommandScript.hash | 2 +- .../src/main/scripts/CommandScript.rs2asm | 196 ++++++++---------- 2 files changed, 90 insertions(+), 108 deletions(-) diff --git a/runelite-client/src/main/scripts/CommandScript.hash b/runelite-client/src/main/scripts/CommandScript.hash index 7a201bd5cb..278821a1de 100644 --- a/runelite-client/src/main/scripts/CommandScript.hash +++ b/runelite-client/src/main/scripts/CommandScript.hash @@ -1 +1 @@ -9B38CB6BF195C49B10D856C5F571AFDEC7BBEF96A4E3532F5B23E9341066144C \ No newline at end of file +3218E18002C110E4D44C9CB0C006BD5C052AC1CA8D07B32F2C67CBD866570F06 \ No newline at end of file diff --git a/runelite-client/src/main/scripts/CommandScript.rs2asm b/runelite-client/src/main/scripts/CommandScript.rs2asm index e56d68fcec..0cb44b4ee8 100644 --- a/runelite-client/src/main/scripts/CommandScript.rs2asm +++ b/runelite-client/src/main/scripts/CommandScript.rs2asm @@ -90,13 +90,13 @@ LABEL60: iload 0 iconst 84 if_icmpeq LABEL76 - jump LABEL822 + jump LABEL809 LABEL76: invoke 1984 iload 2 iconst 0 if_icmpgt LABEL81 - jump LABEL821 + jump LABEL808 LABEL81: iload 3 iconst 1 @@ -699,7 +699,7 @@ LABEL587: sconst "You are not chatting as a guest in a clan channel at the moment." mes LABEL589: - jump LABEL817 + jump LABEL804 LABEL590: iload 5 iconst 41 @@ -782,7 +782,7 @@ LABEL655: sconst "You are not chatting in the channel of your Clan at the moment." mes LABEL657: - jump LABEL817 + jump LABEL804 LABEL658: iload 5 iconst 9 @@ -842,7 +842,7 @@ LABEL699: iconst -1 invoke 5517 LABEL705: - jump LABEL817 + jump LABEL804 LABEL706: iload 5 iconst 2 @@ -858,17 +858,17 @@ LABEL710: iconst 0 iload 9 invoke 5517 - jump LABEL817 + jump LABEL804 LABEL720: iload 4 iconst 1 if_icmpeq LABEL724 - jump LABEL811 + jump LABEL798 LABEL724: iload 2 iconst 2 if_icmpgt LABEL728 - jump LABEL804 + jump LABEL791 LABEL728: get_varc_string 335 sconst "::toggleroof" @@ -876,80 +876,62 @@ LABEL728: string_indexof_string iconst 0 if_icmpeq LABEL735 - jump LABEL763 -LABEL735: - getremoveroofs - iconst 1 - if_icmpeq LABEL739 - jump LABEL751 -LABEL739: - iconst 0 - setremoveroofs - get_varbit 12378 - iconst 0 - if_icmpeq LABEL745 - jump LABEL748 -LABEL745: - sconst "Roofs will only be removed selectively." - mes jump LABEL750 -LABEL748: +LABEL735: + iconst 1 + 3215 + iconst 1 + if_icmpeq LABEL740 + jump LABEL745 +LABEL740: + iconst 0 + invoke 4583 sconst "Roofs will only be removed selectively. This setting will not be saved." mes -LABEL750: - jump LABEL762 -LABEL751: + jump LABEL749 +LABEL745: iconst 1 - setremoveroofs - get_varbit 12378 - iconst 1 - if_icmpeq LABEL757 - jump LABEL760 -LABEL757: - sconst "Roofs are now all hidden." - mes - jump LABEL762 -LABEL760: + invoke 4583 sconst "Roofs are now all hidden. This setting will not be saved." mes -LABEL762: - jump LABEL803 -LABEL763: +LABEL749: + jump LABEL790 +LABEL750: get_varc_string 335 sconst "::wiki " iconst 0 string_indexof_string iconst 0 - if_icmpeq LABEL775 + if_icmpeq LABEL762 get_varc_string 335 sconst "::wiki" compare iconst 0 - if_icmpeq LABEL775 + if_icmpeq LABEL762 sconst "runeliteCommand" ; load callback name runelite_callback ; invoke callback - jump LABEL778 -LABEL775: + jump LABEL765 +LABEL762: get_varc_string 335 invoke 3299 - jump LABEL803 -LABEL778: + jump LABEL790 +LABEL765: get_varc_string 335 sconst "::bank" iconst 0 string_indexof_string iconst 0 - if_icmpeq LABEL785 - jump LABEL792 -LABEL785: + if_icmpeq LABEL772 + jump LABEL779 +LABEL772: sconst "Hey, everyone, I just tried to do something very silly!" iconst 0 iconst -1 iconst 0 iconst -1 invoke 5517 - jump LABEL803 -LABEL792: + jump LABEL790 +LABEL779: get_varc_string 335 invoke 224 set_varc_string 335 @@ -961,97 +943,97 @@ LABEL792: iload 2 substring docheat -LABEL803: - jump LABEL810 -LABEL804: +LABEL790: + jump LABEL797 +LABEL791: get_varc_string 335 iconst 0 iconst -1 iconst 0 iconst -1 invoke 5517 -LABEL810: - jump LABEL817 -LABEL811: +LABEL797: + jump LABEL804 +LABEL798: get_varc_string 335 iconst 0 iconst -1 iconst 1 iload 9 invoke 5517 -LABEL817: +LABEL804: get_varc_string 335 invoke 77 sconst "" set_varc_string 335 -LABEL821: - jump LABEL897 -LABEL822: +LABEL808: + jump LABEL884 +LABEL809: iload 0 iconst 104 - if_icmpeq LABEL826 - jump LABEL832 -LABEL826: + if_icmpeq LABEL813 + jump LABEL819 +LABEL813: iload 3 iconst 1 - if_icmpeq LABEL830 - jump LABEL831 -LABEL830: + if_icmpeq LABEL817 + jump LABEL818 +LABEL817: invoke 75 -LABEL831: - jump LABEL897 -LABEL832: +LABEL818: + jump LABEL884 +LABEL819: iload 0 iconst 105 - if_icmpeq LABEL836 - jump LABEL842 -LABEL836: + if_icmpeq LABEL823 + jump LABEL829 +LABEL823: iload 3 iconst 1 - if_icmpeq LABEL840 - jump LABEL841 -LABEL840: + if_icmpeq LABEL827 + jump LABEL828 +LABEL827: invoke 76 -LABEL841: - jump LABEL897 -LABEL842: +LABEL828: + jump LABEL884 +LABEL829: iload 0 iconst 80 - if_icmpeq LABEL846 - jump LABEL891 -LABEL846: + if_icmpeq LABEL833 + jump LABEL878 +LABEL833: iconst 40697936 iconst 1 cc_find iconst 1 - if_icmpeq LABEL852 - jump LABEL853 -LABEL852: + if_icmpeq LABEL839 + jump LABEL840 +LABEL839: return -LABEL853: +LABEL840: get_varc_string 356 string_length iconst 0 - if_icmpgt LABEL858 - jump LABEL878 -LABEL858: + if_icmpgt LABEL845 + jump LABEL865 +LABEL845: get_varc_string 356 friend_test iconst 1 - if_icmpeq LABEL863 - jump LABEL866 -LABEL863: + if_icmpeq LABEL850 + jump LABEL853 +LABEL850: get_varc_string 356 invoke 107 return -LABEL866: +LABEL853: get_varc_int 60 clientclock - if_icmpgt LABEL870 - jump LABEL871 -LABEL870: + if_icmpgt LABEL857 + jump LABEL858 +LABEL857: return -LABEL871: +LABEL858: clientclock iconst 50 add @@ -1059,14 +1041,14 @@ LABEL871: sconst "That player was not found on your Friends list." mes return -LABEL878: +LABEL865: get_varc_int 60 clientclock - if_icmpgt LABEL882 - jump LABEL883 -LABEL882: + if_icmpgt LABEL869 + jump LABEL870 +LABEL869: return -LABEL883: +LABEL870: clientclock iconst 50 add @@ -1074,8 +1056,8 @@ LABEL883: sconst "You haven't received any messages to which you can reply." mes return - jump LABEL897 -LABEL891: + jump LABEL884 +LABEL878: get_varc_string 335 iconst 0 iload 0 @@ -1087,9 +1069,9 @@ LABEL891: runelite_callback ; if_icmpeq SKIPSETVARC ; skip setting varc with input set_varc_string 335 - jump LABEL897 ; jump over SKIPSETVARC + jump LABEL884 ; jump over SKIPSETVARC SKIPSETVARC: pop_string ; pop message -LABEL897: +LABEL884: invoke 223 return