From a30008ed6260ceb7cee855524b7aa8cae7423779 Mon Sep 17 00:00:00 2001 From: Cyborger1 <45152844+Cyborger1@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:23:55 -0500 Subject: [PATCH] Use simplified menuoption lookup logic from hiscore plugin https://github.com/runelite/runelite/blob/6e34fb4c9dcb57e0ffe67ccf26f1451eca0b8059/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePlugin.java#L150-L166 --- .../com/botdetector/BotDetectorPlugin.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/botdetector/BotDetectorPlugin.java b/src/main/java/com/botdetector/BotDetectorPlugin.java index 2064f558..d8512b46 100644 --- a/src/main/java/com/botdetector/BotDetectorPlugin.java +++ b/src/main/java/com/botdetector/BotDetectorPlugin.java @@ -144,10 +144,6 @@ public class BotDetectorPlugin extends Plugin private static final String PREDICT_OPTION = "Predict"; private static final String REPORT_OPTION = "Report"; - private static final String KICK_OPTION = "Kick"; - private static final String DELETE_OPTION = "Delete"; - private static final ImmutableSet AFTER_OPTIONS = - ImmutableSet.of("Message", "Add ignore", "Remove friend", DELETE_OPTION, KICK_OPTION); private static final ImmutableSet PLAYER_MENU_ACTIONS = ImmutableSet.of( MenuAction.PLAYER_FIRST_OPTION, MenuAction.PLAYER_SECOND_OPTION, MenuAction.PLAYER_THIRD_OPTION, MenuAction.PLAYER_FOURTH_OPTION, @@ -962,21 +958,23 @@ private void onMenuEntryAdded(MenuEntryAdded event) return; } + if (event.getType() != MenuAction.CC_OP.getId() && event.getType() != MenuAction.CC_OP_LOW_PRIORITY.getId()) + { + return; + } + final int componentId = event.getActionParam1(); final int groupId = WidgetUtil.componentToInterface(componentId); final String option = event.getOption(); - if (groupId == InterfaceID.FRIEND_LIST || groupId == InterfaceID.FRIENDS_CHAT || - groupId == InterfaceID.CHATBOX && !KICK_OPTION.equals(option) || - groupId == InterfaceID.RAIDING_PARTY || groupId == InterfaceID.PRIVATE_CHAT || - groupId == InterfaceID.IGNORE_LIST || groupId == InterfaceID.GROUP_IRON || - componentId == ComponentID.CLAN_MEMBERS || componentId == ComponentID.CLAN_GUEST_MEMBERS) + if (groupId == InterfaceID.FRIEND_LIST && option.equals("Delete") + || groupId == InterfaceID.FRIENDS_CHAT && (option.equals("Add ignore") || option.equals("Remove friend")) + || groupId == InterfaceID.CHATBOX && (option.equals("Add ignore") || option.equals("Message")) + || groupId == InterfaceID.IGNORE_LIST && option.equals("Delete") + || (componentId == ComponentID.CLAN_MEMBERS || componentId == ComponentID.CLAN_GUEST_MEMBERS) && (option.equals("Add ignore") || option.equals("Remove friend")) + || groupId == InterfaceID.PRIVATE_CHAT && (option.equals("Add ignore") || option.equals("Message")) + || groupId == InterfaceID.GROUP_IRON && (option.equals("Add friend") || option.equals("Remove friend") || option.equals("Remove ignore"))) { - if (!AFTER_OPTIONS.contains(option) || (option.equals(DELETE_OPTION) && groupId != InterfaceID.IGNORE_LIST)) - { - return; - } - // TODO: Properly use the new menu entry callbacks client.createMenuEntry(-1) .setOption(getPredictOption(event.getTarget()))