diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index fb228c8b05c..8239969c420 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -61,7 +61,6 @@ import net.runelite.api.NPCComposition; import net.runelite.api.ObjectComposition; import net.runelite.api.ParamID; -import net.runelite.api.Varbits; import net.runelite.api.annotations.Component; import net.runelite.api.events.ClientTick; import net.runelite.api.events.MenuEntryAdded; @@ -166,6 +165,7 @@ public class MenuEntrySwapperPlugin extends Plugin private final Multimap swaps = LinkedHashMultimap.create(); private final ArrayListMultimap optionIndexes = ArrayListMultimap.create(); private final Multimap teleportSwaps = HashMultimap.create(); + private boolean lastShift, curShift; @Provides MenuEntrySwapperConfig provideConfig(ConfigManager configManager) @@ -1480,24 +1480,11 @@ private void swapMenuEntry(MenuEntry[] menuEntries, int index, MenuEntry menuEnt final String target = Text.removeTags(menuEntry.getTarget()).toLowerCase(); final Widget w = menuEntry.getParent() != null ? menuEntry.getParent().getWidget() : menuEntry.getWidget(); - final boolean shift = shiftModifier(); // Custom item swap if (w != null && WidgetUtil.componentToInterface(w.getId()) == InterfaceID.INVENTORY - && (shift ? config.shiftClickCustomization() : config.leftClickCustomization())) + && (lastShift ? config.shiftClickCustomization() : config.leftClickCustomization())) { - Integer swapIndex = getItemSwapConfig(shift, w.getItemId()); - if (shift && swapIndex == null && client.getVarbitValue(Varbits.SHIFT_CLICK_DROP) == 1) - { - // Vanilla has 1 tick between the shift keypress and the menu being updated because [proc,inventory_setophelds] - // runs after the ui has been ticked. Work around this here to avoid both the left and shift click swaps - // from being applied. - int shiftOp = itemManager.getItemComposition(w.getItemId()) - .getShiftClickActionIndex(); - if (shiftOp > -1) - { - swapIndex = shiftOp; - } - } + Integer swapIndex = getItemSwapConfig(lastShift, w.getItemId()); if (swapIndex != null) { if (swapIndex == -1) @@ -1520,7 +1507,7 @@ else if (swapIndex + 1 == menuEntry.getItemOp() Widget child = w.getChild(1); if (child != null && child.getItemId() > -1) { - final Integer wornItemSwapConfig = getWornItemSwapConfig(shift, child.getItemId()); + final Integer wornItemSwapConfig = getWornItemSwapConfig(shiftModifier(), child.getItemId()); if (wornItemSwapConfig != null) { if (wornItemSwapConfig == menuEntry.getIdentifier() @@ -1545,7 +1532,7 @@ else if (swapIndex + 1 == menuEntry.getItemOp() objectId = objectComposition.getId(); } - Integer customOption = getObjectSwapConfig(shift, objectId); + Integer customOption = getObjectSwapConfig(shiftModifier(), objectId); if (customOption != null && customOption >= 0) { MenuAction swapAction = OBJECT_MENU_TYPES.get(customOption); @@ -1564,7 +1551,7 @@ else if (swapIndex + 1 == menuEntry.getItemOp() final NPCComposition composition = npc.getTransformedComposition(); assert composition != null; - Integer customOption = getNpcSwapConfig(shift, composition.getId()); + Integer customOption = getNpcSwapConfig(shiftModifier(), composition.getId()); if (customOption != null && customOption >= 0) { MenuAction swapAction = NPC_MENU_TYPES.get(customOption); @@ -1596,7 +1583,7 @@ else if (swapIndex + 1 == menuEntry.getItemOp() { final int componentId = w.getId(); // on dynamic components, this is the parent layer id final int itemId = w.getIndex() == -1 ? -1 : ItemVariationMapping.map(w.getItemId()); - final Integer op = getUiSwapConfig(shift, componentId, itemId); + final Integer op = getUiSwapConfig(shiftModifier(), componentId, itemId); if (op != null && op == menuEntry.getIdentifier()) { swap(optionIndexes, menuEntries, index, menuEntries.length - 1); @@ -1637,6 +1624,9 @@ else if (swapIndex + 1 == menuEntry.getItemOp() @Subscribe public void onClientTick(ClientTick clientTick) { + lastShift = curShift; + curShift = shiftModifier(); + if (client.isMenuOpen()) { return;