menu swapper: check home portal swap target

The swap was attemting to run on anything with the "enter" option, which
conflicted with the quick-enter swap below it.

Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
melkypie
2020-01-10 19:58:05 -05:00
committed by Adam
parent 8ddcb92bd7
commit 2681d395fc
2 changed files with 32 additions and 1 deletions

View File

@@ -498,7 +498,7 @@ public class MenuEntrySwapperPlugin extends Plugin
{
swap("harpoon", option, target, index);
}
else if (config.swapHomePortal() != HouseMode.ENTER && option.equals("enter"))
else if (config.swapHomePortal() != HouseMode.ENTER && option.equals("enter") && target.equals("portal"))
{
switch (config.swapHomePortal())
{

View File

@@ -263,4 +263,35 @@ public class MenuEntrySwapperPluginTest
menu("Cast", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION),
}, argumentCaptor.getValue());
}
@Test
public void testTobDoor()
{
when(config.swapQuick()).thenReturn(true);
when(config.swapHomePortal()).thenReturn(HouseMode.HOME);
//Quick-enter, Enter
entries = new MenuEntry[]{
menu("Cancel", "", MenuAction.CANCEL),
menu("Examine", "Formidable Passage", MenuAction.EXAMINE_OBJECT),
menu("Walk here", "", MenuAction.WALK),
menu("Quick-Enter", "Formidable Passage", MenuAction.GAME_OBJECT_SECOND_OPTION),
menu("Enter", "Formidable Passage", MenuAction.GAME_OBJECT_FIRST_OPTION),
};
menuEntrySwapperPlugin.onClientTick(new ClientTick());
ArgumentCaptor<MenuEntry[]> argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class);
verify(client).setMenuEntries(argumentCaptor.capture());
assertArrayEquals(new MenuEntry[]{
menu("Cancel", "", MenuAction.CANCEL),
menu("Examine", "Formidable Passage", MenuAction.EXAMINE_OBJECT),
menu("Walk here", "", MenuAction.WALK),
menu("Enter", "Formidable Passage", MenuAction.GAME_OBJECT_FIRST_OPTION),
menu("Quick-Enter", "Formidable Passage", MenuAction.GAME_OBJECT_SECOND_OPTION),
}, argumentCaptor.getValue());
}
}