hiscore: simplify lookup menu option add logic
This commit is contained in:
@@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.hiscore;
|
package net.runelite.client.plugins.hiscore;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ObjectArrays;
|
import com.google.common.collect.ObjectArrays;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@@ -70,8 +69,6 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||||||
public class HiscorePlugin extends Plugin
|
public class HiscorePlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final String LOOKUP = "Lookup";
|
private static final String LOOKUP = "Lookup";
|
||||||
private static final String KICK_OPTION = "Kick";
|
|
||||||
private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message", "Add ignore", "Remove friend", "Delete", KICK_OPTION);
|
|
||||||
private static final Pattern BOUNTY_PATTERN = Pattern.compile("<col=ff0000>You've been assigned a target: (.*)</col>");
|
private static final Pattern BOUNTY_PATTERN = Pattern.compile("<col=ff0000>You've been assigned a target: (.*)</col>");
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -153,26 +150,23 @@ public class HiscorePlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuEntryAdded(MenuEntryAdded event)
|
public void onMenuEntryAdded(MenuEntryAdded event)
|
||||||
{
|
{
|
||||||
if (!config.menuOption())
|
if ((event.getType() != MenuAction.CC_OP.getId() && event.getType() != MenuAction.CC_OP_LOW_PRIORITY.getId()) || !config.menuOption())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String option = event.getOption();
|
||||||
final int componentId = event.getActionParam1();
|
final int componentId = event.getActionParam1();
|
||||||
int groupId = WidgetInfo.TO_GROUP(componentId);
|
final int groupId = WidgetInfo.TO_GROUP(componentId);
|
||||||
String option = event.getOption();
|
|
||||||
|
|
||||||
if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId() ||
|
if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() && option.equals("Delete")
|
||||||
groupId == WidgetInfo.CHATBOX.getGroupId() && !KICK_OPTION.equals(option) || //prevent from adding for Kick option (interferes with the raiding party one)
|
|| groupId == WidgetInfo.FRIENDS_CHAT.getGroupId() && (option.equals("Add ignore") || option.equals("Remove friend"))
|
||||||
groupId == WidgetInfo.RAIDING_PARTY.getGroupId() || groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId() ||
|
|| groupId == WidgetInfo.CHATBOX.getGroupId() && (option.equals("Add ignore") || option.equals("Message"))
|
||||||
groupId == WidgetInfo.IGNORE_LIST.getGroupId() || componentId == WidgetInfo.CLAN_MEMBER_LIST.getId() ||
|
|| groupId == WidgetInfo.IGNORE_LIST.getGroupId() && option.equals("Delete")
|
||||||
componentId == WidgetInfo.CLAN_GUEST_MEMBER_LIST.getId())
|
|| (componentId == WidgetInfo.CLAN_MEMBER_LIST.getId() || componentId == WidgetInfo.CLAN_GUEST_MEMBER_LIST.getId()) && (option.equals("Add ignore") || option.equals("Remove friend"))
|
||||||
|
|| groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId() && (option.equals("Add ignore") || option.equals("Message"))
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!AFTER_OPTIONS.contains(option) || (option.equals("Delete") && groupId != WidgetInfo.IGNORE_LIST.getGroupId()))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final MenuEntry lookup = new MenuEntry();
|
final MenuEntry lookup = new MenuEntry();
|
||||||
lookup.setOption(LOOKUP);
|
lookup.setOption(LOOKUP);
|
||||||
lookup.setTarget(event.getTarget());
|
lookup.setTarget(event.getTarget());
|
||||||
|
|||||||
Reference in New Issue
Block a user