Skip to content

Commit

Permalink
Use simplified menuoption lookup logic from hiscore plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyborger1 committed Nov 13, 2023
1 parent 33672e7 commit a30008e
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/main/java/com/botdetector/BotDetectorPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> AFTER_OPTIONS =
ImmutableSet.of("Message", "Add ignore", "Remove friend", DELETE_OPTION, KICK_OPTION);

private static final ImmutableSet<MenuAction> PLAYER_MENU_ACTIONS = ImmutableSet.of(
MenuAction.PLAYER_FIRST_OPTION, MenuAction.PLAYER_SECOND_OPTION, MenuAction.PLAYER_THIRD_OPTION, MenuAction.PLAYER_FOURTH_OPTION,
Expand Down Expand Up @@ -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()))
Expand Down

0 comments on commit a30008e

Please sign in to comment.