Merge pull request #6081 from deathbeam/properly-insert-lookup

Make HiScore lookup always deprioritized
This commit is contained in:
Adam
2018-10-21 15:06:52 -04:00
committed by GitHub

View File

@@ -66,8 +66,7 @@ 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 String KICK_OPTION = "Kick";
private static final ImmutableList<String> BEFORE_OPTIONS = ImmutableList.of("Add friend", "Remove friend", KICK_OPTION); private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message", "Add ignore", "Remove friend", KICK_OPTION);
private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message");
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
@@ -182,15 +181,7 @@ public class HiscorePlugin extends Plugin
{ {
boolean after; boolean after;
if (AFTER_OPTIONS.contains(option)) if (!AFTER_OPTIONS.contains(option))
{
after = true;
}
else if (BEFORE_OPTIONS.contains(option))
{
after = false;
}
else
{ {
return; return;
} }
@@ -203,7 +194,7 @@ public class HiscorePlugin extends Plugin
lookup.setParam1(event.getActionParam1()); lookup.setParam1(event.getActionParam1());
lookup.setIdentifier(event.getIdentifier()); lookup.setIdentifier(event.getIdentifier());
insertMenuEntry(lookup, client.getMenuEntries(), after); insertMenuEntry(lookup, client.getMenuEntries());
} }
} }
@@ -232,16 +223,11 @@ public class HiscorePlugin extends Plugin
} }
} }
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries, boolean after) private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries)
{ {
MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry); MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry);
int menuEntryCount = newMenu.length;
if (after) ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2);
{
int menuEntryCount = newMenu.length;
ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2);
}
client.setMenuEntries(newMenu); client.setMenuEntries(newMenu);
} }