menu entry swapper: add shift click teleport spell swap
Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
@@ -311,4 +311,14 @@ public interface MenuEntrySwapperConfig extends Config
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "swapTeleportSpell",
|
||||||
|
name = "Shift-click teleport spells",
|
||||||
|
description = "Swap teleport spells that have a second destination on shift"
|
||||||
|
)
|
||||||
|
default boolean swapTeleportSpell()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -604,6 +604,38 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
swap("use", option, target, index);
|
swap("use", option, target, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shiftModifier && config.swapTeleportSpell())
|
||||||
|
{
|
||||||
|
if (target.equals("varrock teleport"))
|
||||||
|
{
|
||||||
|
swapTeleport(target, option, "grand exchange", index);
|
||||||
|
}
|
||||||
|
else if (target.equals("camelot teleport"))
|
||||||
|
{
|
||||||
|
swapTeleport(target, option, "seers'", index);
|
||||||
|
}
|
||||||
|
else if (target.equals("watchtower teleport"))
|
||||||
|
{
|
||||||
|
swapTeleport(target, option, "yanille", index);
|
||||||
|
}
|
||||||
|
else if (target.equals("teleport to house"))
|
||||||
|
{
|
||||||
|
swapTeleport(target, option, "outside", index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void swapTeleport(String target, String option, String optionA, int index)
|
||||||
|
{
|
||||||
|
if (option.equals("cast"))
|
||||||
|
{
|
||||||
|
swap(optionA, option, target, index);
|
||||||
|
}
|
||||||
|
else if (option.equals(optionA))
|
||||||
|
{
|
||||||
|
swap("cast", option, target, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldSwapPickpocket(String target)
|
private static boolean shouldSwapPickpocket(String target)
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import static org.mockito.Mockito.clearInvocations;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -209,4 +210,57 @@ public class MenuEntrySwapperPluginTest
|
|||||||
menu("Pay (north)", "Kragen", MenuAction.NPC_THIRD_OPTION),
|
menu("Pay (north)", "Kragen", MenuAction.NPC_THIRD_OPTION),
|
||||||
}, argumentCaptor.getValue());
|
}, argumentCaptor.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTeleport()
|
||||||
|
{
|
||||||
|
when(config.swapTeleportSpell()).thenReturn(true);
|
||||||
|
menuEntrySwapperPlugin.setShiftModifier(true);
|
||||||
|
|
||||||
|
// Cast -> Grand Exchange
|
||||||
|
entries = new MenuEntry[]{
|
||||||
|
menu("Cancel", "", MenuAction.CANCEL),
|
||||||
|
|
||||||
|
menu("Configure", "Varrock Teleport", MenuAction.WIDGET_THIRD_OPTION),
|
||||||
|
menu("Grand Exchange", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION),
|
||||||
|
menu("Cast", "Varrock Teleport", MenuAction.WIDGET_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("Configure", "Varrock Teleport", MenuAction.WIDGET_THIRD_OPTION),
|
||||||
|
menu("Cast", "Varrock Teleport", MenuAction.WIDGET_FIRST_OPTION),
|
||||||
|
menu("Grand Exchange", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION),
|
||||||
|
}, argumentCaptor.getValue());
|
||||||
|
|
||||||
|
clearInvocations(client);
|
||||||
|
|
||||||
|
// Grand Exchange -> Cast
|
||||||
|
entries = new MenuEntry[]{
|
||||||
|
menu("Cancel", "", MenuAction.CANCEL),
|
||||||
|
|
||||||
|
menu("Configure", "Varrock Teleport", MenuAction.WIDGET_THIRD_OPTION),
|
||||||
|
menu("Cast", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION),
|
||||||
|
menu("Grand Exchange", "Varrock Teleport", MenuAction.WIDGET_FIRST_OPTION),
|
||||||
|
};
|
||||||
|
|
||||||
|
menuEntrySwapperPlugin.onClientTick(new ClientTick());
|
||||||
|
|
||||||
|
argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class);
|
||||||
|
verify(client).setMenuEntries(argumentCaptor.capture());
|
||||||
|
|
||||||
|
assertArrayEquals(new MenuEntry[]{
|
||||||
|
menu("Cancel", "", MenuAction.CANCEL),
|
||||||
|
|
||||||
|
menu("Configure", "Varrock Teleport", MenuAction.WIDGET_THIRD_OPTION),
|
||||||
|
menu("Grand Exchange", "Varrock Teleport", MenuAction.WIDGET_FIRST_OPTION),
|
||||||
|
menu("Cast", "Varrock Teleport", MenuAction.WIDGET_SECOND_OPTION),
|
||||||
|
}, argumentCaptor.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user