From 99afd3e0b71cd20ef2bc909f2082761a442767ca Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Wed, 24 Jun 2020 17:01:52 -0700 Subject: [PATCH 01/10] ClientUI: Fix panel toggle after closing with click This commit ensures the previously-active plugin panel can be reopened with the plugin panel toggle hotkey after being closed via mouse click. --- .../src/main/java/net/runelite/client/ui/ClientUI.java | 1 - 1 file changed, 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 448c3179a6..4232882f74 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -206,7 +206,6 @@ public class ClientUI currentButton.setSelected(false); currentNavButton.setSelected(false); currentButton = null; - currentNavButton = null; } else { From 6ccaf8876c3fcd97b27ad91653ce6949315f29ee Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Wed, 24 Jun 2020 17:28:47 -0700 Subject: [PATCH 02/10] bank plugin: Remove ContainerCalculation class This commit removes the hashing feature from container calculation which alone would make obsolete the ContainerCalculation class, so it additionally inlines the `calculate()` method into the plugin class. Additionally, this commit adds null handling for the items parameter of `calculate()` to prevent NPEs. --- .../client/plugins/bank/BankPlugin.java | 55 +++++++-- .../plugins/bank/ContainerCalculation.java | 111 ------------------ .../client/plugins/bank/BankPluginTest.java | 29 +++++ .../bank/ContainerCalculationTest.java | 93 --------------- 4 files changed, 76 insertions(+), 212 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/bank/ContainerCalculation.java delete mode 100644 runelite-client/src/test/java/net/runelite/client/plugins/bank/ContainerCalculationTest.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java index 0153dbb5e2..fbbd834ed8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java @@ -36,9 +36,11 @@ import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.Nullable; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; +import net.runelite.api.Constants; import static net.runelite.api.Constants.HIGH_ALCHEMY_MULTIPLIER; import net.runelite.api.InventoryID; import net.runelite.api.Item; @@ -115,12 +117,6 @@ public class BankPlugin extends Plugin @Inject private BankSearch bankSearch; - @Inject - private ContainerCalculation bankCalculation; - - @Inject - private ContainerCalculation seedVaultCalculation; - private boolean forceRightClickFlag; private Multiset itemQuantities; // bank item quantities for bank value search private String searchString; @@ -184,7 +180,7 @@ public class BankPlugin extends Plugin switch (event.getEventName()) { case "setBankTitle": - final ContainerPrices prices = bankCalculation.calculate(getBankTabItems()); + final ContainerPrices prices = calculate(getBankTabItems()); if (prices == null) { return; @@ -375,7 +371,7 @@ public class BankPlugin extends Plugin return; } - final ContainerPrices prices = seedVaultCalculation.calculate(getSeedVaultItems()); + final ContainerPrices prices = calculate(getSeedVaultItems()); if (prices == null) { return; @@ -493,4 +489,47 @@ public class BankPlugin extends Plugin } return set; } + + @Nullable + ContainerPrices calculate(@Nullable Item[] items) + { + if (items == null) + { + return null; + } + + long ge = 0; + long alch = 0; + + for (final Item item : items) + { + final int qty = item.getQuantity(); + final int id = item.getId(); + + if (id <= 0 || qty == 0) + { + continue; + } + + switch (id) + { + case ItemID.COINS_995: + ge += qty; + alch += qty; + break; + case ItemID.PLATINUM_TOKEN: + ge += qty * 1000L; + alch += qty * 1000L; + break; + default: + final long storePrice = itemManager.getItemComposition(id).getPrice(); + final long alchPrice = (long) (storePrice * Constants.HIGH_ALCHEMY_MULTIPLIER); + alch += alchPrice * qty; + ge += (long) itemManager.getItemPrice(id) * qty; + break; + } + } + + return new ContainerPrices(ge, alch); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/bank/ContainerCalculation.java b/runelite-client/src/main/java/net/runelite/client/plugins/bank/ContainerCalculation.java deleted file mode 100644 index ca383bc81a..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/bank/ContainerCalculation.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2019, TheStonedTurtle - * Copyright (c) 2019, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.bank; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Nullable; -import javax.inject.Inject; -import net.runelite.api.Constants; -import net.runelite.api.Item; -import net.runelite.api.ItemID; -import net.runelite.client.game.ItemManager; - -class ContainerCalculation -{ - private final ItemManager itemManager; - - private int hash; - private ContainerPrices containerPrices; - - @Inject - private ContainerCalculation(ItemManager itemManager) - { - this.itemManager = itemManager; - } - - @Nullable - ContainerPrices calculate(Item[] items) - { - // Returns last calculation if inventory hasn't changed - final int newHash = hashItems(items); - if (containerPrices != null && hash == newHash) - { - return containerPrices; - } - - hash = newHash; - - long ge = 0; - long alch = 0; - - for (final Item item : items) - { - final int qty = item.getQuantity(); - final int id = item.getId(); - - if (id <= 0 || qty == 0) - { - continue; - } - - switch (id) - { - case ItemID.COINS_995: - ge += qty; - alch += qty; - break; - case ItemID.PLATINUM_TOKEN: - ge += qty * 1000L; - alch += qty * 1000L; - break; - default: - final long storePrice = itemManager.getItemComposition(id).getPrice(); - final long alchPrice = (long) (storePrice * Constants.HIGH_ALCHEMY_MULTIPLIER); - alch += alchPrice * qty; - ge += (long) itemManager.getItemPrice(id) * qty; - break; - } - - } - - ContainerPrices prices = new ContainerPrices(ge, alch); - containerPrices = prices; - - return prices; - } - - private int hashItems(final Item[] items) - { - final Map mapCheck = new HashMap<>(items.length); - for (Item item : items) - { - mapCheck.put(item.getId(), item.getQuantity()); - } - - return mapCheck.hashCode(); - } -} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankPluginTest.java index bc9caff9da..03424d7d01 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankPluginTest.java @@ -25,6 +25,7 @@ */ package net.runelite.client.plugins.bank; +import com.google.common.collect.ImmutableList; import com.google.inject.Guice; import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; @@ -37,6 +38,7 @@ import net.runelite.api.ItemContainer; import net.runelite.api.ItemID; import net.runelite.client.game.ItemManager; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; @@ -105,4 +107,31 @@ public class BankPluginTest assertFalse(bankPlugin.valueSearch(itemId, "1000k")); } + + @Test + public void testCalculate() + { + Item coins = new Item(ItemID.COINS_995, Integer.MAX_VALUE); + + Item whip = new Item(ItemID.ABYSSAL_WHIP, 1_000_000_000); + + Item[] items = ImmutableList.of( + coins, + whip + ).toArray(new Item[0]); + + ItemComposition whipComp = mock(ItemComposition.class); + when(whipComp.getPrice()) + .thenReturn(7); // 7 * .6 = 4, 4 * 1m overflows + when(itemManager.getItemComposition(ItemID.ABYSSAL_WHIP)) + .thenReturn(whipComp); + when(itemManager.getItemPrice(ItemID.ABYSSAL_WHIP)) + .thenReturn(3); // 1b * 3 overflows + + final ContainerPrices prices = bankPlugin.calculate(items); + assertNotNull(prices); + + assertTrue(prices.getHighAlchPrice() > Integer.MAX_VALUE); + assertTrue(prices.getGePrice() > Integer.MAX_VALUE); + } } \ No newline at end of file diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/bank/ContainerCalculationTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/bank/ContainerCalculationTest.java deleted file mode 100644 index 1f220f4b64..0000000000 --- a/runelite-client/src/test/java/net/runelite/client/plugins/bank/ContainerCalculationTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2019, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.bank; - -import com.google.common.collect.ImmutableList; -import com.google.inject.Guice; -import com.google.inject.testing.fieldbinder.Bind; -import com.google.inject.testing.fieldbinder.BoundFieldModule; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.Item; -import net.runelite.api.ItemComposition; -import net.runelite.api.ItemID; -import net.runelite.client.game.ItemManager; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import org.mockito.junit.MockitoJUnitRunner; - -@RunWith(MockitoJUnitRunner.class) -public class ContainerCalculationTest -{ - @Mock - @Bind - private Client client; - - @Mock - @Bind - private ItemManager itemManager; - - @Inject - private ContainerCalculation containerCalculation; - - @Before - public void before() - { - Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); - } - - @Test - public void testCalculate() - { - Item coins = new Item(ItemID.COINS_995, Integer.MAX_VALUE); - - Item whip = new Item(ItemID.ABYSSAL_WHIP, 1_000_000_000); - - Item[] items = ImmutableList.of( - coins, - whip - ).toArray(new Item[0]); - - ItemComposition whipComp = mock(ItemComposition.class); - when(whipComp.getPrice()) - .thenReturn(7); // 7 * .6 = 4, 4 * 1m overflows - when(itemManager.getItemComposition(ItemID.ABYSSAL_WHIP)) - .thenReturn(whipComp); - when(itemManager.getItemPrice(ItemID.ABYSSAL_WHIP)) - .thenReturn(3); // 1b * 3 overflows - - final ContainerPrices prices = containerCalculation.calculate(items); - assertNotNull(prices); - - assertTrue(prices.getHighAlchPrice() > Integer.MAX_VALUE); - assertTrue(prices.getGePrice() > Integer.MAX_VALUE); - } -} From 2f57643f28b1890f283543ac6623a619231e8a73 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 25 Jun 2020 23:04:31 -0400 Subject: [PATCH 03/10] menuentryswapper: Fix claim slime swap --- .../client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6353eebe11..92b56babb9 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 @@ -197,7 +197,7 @@ public class MenuEntrySwapperPlugin extends Plugin swap("talk-to", "trade", config::swapTrade); swap("talk-to", "trade-with", config::swapTrade); swap("talk-to", "shop", config::swapTrade); - swap("talk-to", "robin", "claim-slime", config::swapTrade); + swap("talk-to", "robin", "claim-slime", config::claimSlime); swap("talk-to", "travel", config::swapTravel); swap("talk-to", "pay-fare", config::swapTravel); swap("talk-to", "charter", config::swapTravel); From 78a3ccd586cc89cbf114b21d24656f1bf31e64be Mon Sep 17 00:00:00 2001 From: Max Weber Date: Thu, 25 Jun 2020 22:18:01 -0600 Subject: [PATCH 04/10] ClientUI: Allow hotkey plugin panel toggles on login screen --- .../src/main/java/net/runelite/client/ui/ClientUI.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 4232882f74..a5d85c577b 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -382,7 +382,6 @@ public class ClientUI toggleSidebar(); } }; - sidebarListener.setEnabledOnLogin(true); keyManager.registerKeyListener(sidebarListener); @@ -394,7 +393,7 @@ public class ClientUI togglePluginPanel(); } }; - + pluginPanelListener.setEnabledOnLogin(true); keyManager.registerKeyListener(pluginPanelListener); // Add mouse listener @@ -412,7 +411,6 @@ public class ClientUI return mouseEvent; } }; - mouseManager.registerMouseListener(mouseListener); // Decorate window with custom chrome and titlebar if needed From e3056b8000dfbe20df833efc32bef9ac8a6d8ac4 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Fri, 26 Jun 2020 00:13:51 -0700 Subject: [PATCH 05/10] AnagramClue: Fix Cam the Camel elite step text --- .../runelite/client/plugins/cluescrolls/clues/AnagramClue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java index b954168fae..28d848a5b3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java @@ -115,7 +115,7 @@ public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueSc new AnagramClue("LADDER MEMO GUV", "Guard Vemmeldo", new WorldPoint(2447, 3418, 1), "Gnome Stronghold Bank", "How many magic trees can you find inside the Gnome Stronghold?", "3"), new AnagramClue("MAL IN TAU", "Luminata", new WorldPoint(3508, 3237, 0), "Near Burgh de Rott entrance"), new AnagramClue("ME AM THE CALC", "Cam the Camel", new WorldPoint(3300, 3231, 0), "Outside Duel Arena"), - new AnagramClue("MACHETE CLAM", "Cam the Camel", new WorldPoint(3300, 3231, 0), "Outside Duel Arena", "How many items can carry water in RuneScape?", "6"), + new AnagramClue("MACHETE CLAM", "Cam the Camel", new WorldPoint(3300, 3231, 0), "Outside Duel Arena", "How many items can carry water in Gielinor?", "6"), new AnagramClue("ME IF", "Femi", new WorldPoint(2461, 3382, 0), "Gates of Tree Gnome Stronghold"), new AnagramClue("MOLD LA RAN", "Old Man Ral", new WorldPoint(3602, 3209, 0), "Meiyerditch"), new AnagramClue("MOTHERBOARD", "Brother Omad", new WorldPoint(2606, 3211, 0), "Monastery south of Ardougne", "What is the next number? 12, 13, 15, 17, 111, 113, 117, 119, 123....?", "129"), From 924064ddc525c79d656c1e81bc5b944d78fdf4b4 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Jun 2020 22:09:05 -0400 Subject: [PATCH 06/10] overlay renderer: avoid unnecessary cursor reset on key release or focus lost --- .../runelite/client/ui/overlay/OverlayRenderer.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java index a2419df6a8..c552ac9de4 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java @@ -124,8 +124,12 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener { if (!event.isFocused()) { - inOverlayManagingMode = false; - resetOverlayManagementMode(); + if (inOverlayManagingMode) + { + inOverlayManagingMode = false; + resetOverlayManagementMode(); + } + inMenuEntryMode = false; menuEntries = null; } @@ -596,7 +600,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener @Override public void keyReleased(KeyEvent e) { - if (!e.isAltDown()) + if (!e.isAltDown() && inOverlayManagingMode) { inOverlayManagingMode = false; resetOverlayManagementMode(); From 1e1273d1726a58812c6e7c1cde70ff6d88f7eb46 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Jun 2020 20:51:14 -0400 Subject: [PATCH 07/10] menu swapper: fix toggling customizable shift-click option This was not actually enabling/disabling shift click on config toggle, nor was it respecting the config option when overwriting the shift click indexes --- .../MenuEntrySwapperConfig.java | 4 ++- .../MenuEntrySwapperPlugin.java | 26 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index e3d50db7f4..6ca722c229 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -29,9 +29,11 @@ import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigSection; -@ConfigGroup("menuentryswapper") +@ConfigGroup(MenuEntrySwapperConfig.GROUP) public interface MenuEntrySwapperConfig extends Config { + String GROUP = "menuentryswapper"; + @ConfigSection( name = "Item Swaps", description = "All options that swap item menu entries", 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 92b56babb9..27ec421c69 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 @@ -85,7 +85,7 @@ public class MenuEntrySwapperPlugin extends Plugin private static final String RESET = "Reset"; private static final String MENU_TARGET = "Shift-click"; - private static final String CONFIG_GROUP = "shiftclick"; + private static final String SHIFTCLICK_CONFIG_GROUP = "shiftclick"; private static final String ITEM_KEY_PREFIX = "item_"; private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE, @@ -389,12 +389,7 @@ public class MenuEntrySwapperPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { - if (!CONFIG_GROUP.equals(event.getGroup())) - { - return; - } - - if (event.getKey().equals("shiftClickCustomization")) + if (event.getGroup().equals(MenuEntrySwapperConfig.GROUP) && event.getKey().equals("shiftClickCustomization")) { if (config.shiftClickCustomization()) { @@ -405,7 +400,7 @@ public class MenuEntrySwapperPlugin extends Plugin disableCustomization(); } } - else if (event.getKey().startsWith(ITEM_KEY_PREFIX)) + else if (event.getGroup().equals(SHIFTCLICK_CONFIG_GROUP) && event.getKey().startsWith(ITEM_KEY_PREFIX)) { clientThread.invoke(this::resetItemCompositionCache); } @@ -420,7 +415,7 @@ public class MenuEntrySwapperPlugin extends Plugin private Integer getSwapConfig(int itemId) { itemId = ItemVariationMapping.map(itemId); - String config = configManager.getConfiguration(CONFIG_GROUP, ITEM_KEY_PREFIX + itemId); + String config = configManager.getConfiguration(SHIFTCLICK_CONFIG_GROUP, ITEM_KEY_PREFIX + itemId); if (config == null || config.isEmpty()) { return null; @@ -432,19 +427,20 @@ public class MenuEntrySwapperPlugin extends Plugin private void setSwapConfig(int itemId, int index) { itemId = ItemVariationMapping.map(itemId); - configManager.setConfiguration(CONFIG_GROUP, ITEM_KEY_PREFIX + itemId, index); + configManager.setConfiguration(SHIFTCLICK_CONFIG_GROUP, ITEM_KEY_PREFIX + itemId, index); } private void unsetSwapConfig(int itemId) { itemId = ItemVariationMapping.map(itemId); - configManager.unsetConfiguration(CONFIG_GROUP, ITEM_KEY_PREFIX + itemId); + configManager.unsetConfiguration(SHIFTCLICK_CONFIG_GROUP, ITEM_KEY_PREFIX + itemId); } private void enableCustomization() { keyManager.registerKeyListener(inputListener); refreshShiftClickCustomizationMenus(); + // set shift click action index on the item compositions clientThread.invoke(this::resetItemCompositionCache); } @@ -453,6 +449,7 @@ public class MenuEntrySwapperPlugin extends Plugin keyManager.unregisterKeyListener(inputListener); removeShiftClickCustomizationMenus(); configuringShiftClick = false; + // flush item compositions to reset the shift click action index clientThread.invoke(this::resetItemCompositionCache); } @@ -707,6 +704,13 @@ public class MenuEntrySwapperPlugin extends Plugin @Subscribe public void onPostItemComposition(PostItemComposition event) { + if (!config.shiftClickCustomization()) + { + // since shift-click is done by the client we have to check if our shift click customization is on + // prior to altering the item shift click action index. + return; + } + ItemComposition itemComposition = event.getItemComposition(); Integer option = getSwapConfig(itemComposition.getId()); From 31c66294f09bb8fefd1691601bf4cd7906864779 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Jun 2020 20:55:23 -0400 Subject: [PATCH 08/10] menu swapper: don't apply item menu swaps when shift is held This fixes a regression where applying menu swaps post-shift would make shift effectively do nothing. Instead use the client swap when shift is held. --- .../MenuEntrySwapperPlugin.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) 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 27ec421c69..23cd79d44e 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 @@ -633,30 +633,40 @@ public class MenuEntrySwapperPlugin extends Plugin private void swapMenuEntry(int index, MenuEntry menuEntry) { final int eventId = menuEntry.getIdentifier(); + final MenuAction menuAction = MenuAction.of(menuEntry.getType()); final String option = Text.removeTags(menuEntry.getOption()).toLowerCase(); final String target = Text.removeTags(menuEntry.getTarget()).toLowerCase(); final NPC hintArrowNpc = client.getHintArrowNpc(); if (hintArrowNpc != null && hintArrowNpc.getIndex() == eventId - && NPC_MENU_TYPES.contains(MenuAction.of(menuEntry.getType()))) + && NPC_MENU_TYPES.contains(menuAction)) { return; } - // Special case use shift click due to items not actually containing a "Use" option, making - // the client unable to perform the swap itself. - if (shiftModifier && config.shiftClickCustomization() && !option.equals("use")) + if (shiftModifier && (menuAction == MenuAction.ITEM_FIRST_OPTION + || menuAction == MenuAction.ITEM_SECOND_OPTION + || menuAction == MenuAction.ITEM_THIRD_OPTION + || menuAction == MenuAction.ITEM_FOURTH_OPTION + || menuAction == MenuAction.ITEM_FIFTH_OPTION + || menuAction == MenuAction.ITEM_USE)) { - Integer customOption = getSwapConfig(eventId); - - if (customOption != null && customOption == -1) + // Special case use shift click due to items not actually containing a "Use" option, making + // the client unable to perform the swap itself. + if (config.shiftClickCustomization() && !option.equals("use")) { - if (swap("use", target, index, true)) + Integer customOption = getSwapConfig(eventId); + + if (customOption != null && customOption == -1) { - return; + swap("use", target, index, true); } } + + // don't perform swaps on items when shift is held; instead prefer the client menu swap, which + // we may have overwrote + return; } Collection swaps = this.swaps.get(option); From 15339291911f49d1ad6073449914a32256efd95c Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Jun 2020 21:26:35 -0400 Subject: [PATCH 09/10] api: add isKeyPressed --- .../main/java/net/runelite/api/Client.java | 8 +++++ .../main/java/net/runelite/api/KeyCode.java | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 runelite-api/src/main/java/net/runelite/api/KeyCode.java diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 356a1e5690..94c7174325 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -1762,4 +1762,12 @@ public interface Client extends GameEngine * Sets whether the flames on the login screen should be rendered */ void setShouldRenderLoginScreenFire(boolean val); + + /** + * Test if a key is pressed + * @param keycode the keycode + * @return + * @see KeyCode + */ + boolean isKeyPressed(int keycode); } diff --git a/runelite-api/src/main/java/net/runelite/api/KeyCode.java b/runelite-api/src/main/java/net/runelite/api/KeyCode.java new file mode 100644 index 0000000000..66770d8b6a --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/KeyCode.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api; + +/** + * Jagex key codes + */ +public final class KeyCode +{ + public static final int KC_SHIFT = 81; +} From edbf5d22e19ee7a5b5fdfbda363a4bcd6bb76be6 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Jun 2020 21:26:58 -0400 Subject: [PATCH 10/10] client: update to use isKeyPressed --- .../plugins/banktags/BankTagsPlugin.java | 49 +--------- .../GroundMarkerInputListener.java | 67 ------------- .../groundmarkers/GroundMarkerPlugin.java | 22 +---- .../MenuEntrySwapperPlugin.java | 95 ++++++++----------- .../ShiftClickInputListener.java | 67 ------------- .../npchighlight/NpcIndicatorsInput.java | 61 ------------ .../npchighlight/NpcIndicatorsPlugin.java | 22 +---- .../ObjectIndicatorsPlugin.java | 45 +-------- .../client/plugins/party/PartyPlugin.java | 46 +-------- .../MenuEntrySwapperPluginTest.java | 7 +- 10 files changed, 61 insertions(+), 420 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerInputListener.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsInput.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/BankTagsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/BankTagsPlugin.java index 08a0a3aab7..607861bfd8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/BankTagsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/BankTagsPlugin.java @@ -29,14 +29,13 @@ package net.runelite.client.plugins.banktags; import com.google.common.collect.Lists; import com.google.common.primitives.Shorts; import com.google.inject.Provides; -import java.awt.event.KeyEvent; import java.awt.event.MouseWheelEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.Set; import java.util.TreeSet; -import java.util.List; import java.util.function.Consumer; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -46,13 +45,12 @@ import net.runelite.api.InventoryID; import net.runelite.api.Item; import net.runelite.api.ItemComposition; import net.runelite.api.ItemContainer; +import net.runelite.api.KeyCode; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.VarClientInt; import net.runelite.api.VarClientStr; -import net.runelite.client.events.ConfigChanged; import net.runelite.api.events.DraggingWidgetChanged; -import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.GrandExchangeSearched; import net.runelite.api.events.MenuEntryAdded; @@ -66,11 +64,11 @@ import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemVariationMapping; import net.runelite.client.game.SpriteManager; import net.runelite.client.game.chatbox.ChatboxPanelManager; -import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyManager; import net.runelite.client.input.MouseManager; import net.runelite.client.input.MouseWheelListener; @@ -90,7 +88,7 @@ import net.runelite.client.util.Text; tags = {"searching", "tagging"} ) @PluginDependency(ClueScrollPlugin.class) -public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyListener +public class BankTagsPlugin extends Plugin implements MouseWheelListener { public static final String CONFIG_GROUP = "banktags"; public static final String TAG_SEARCH = "tag:"; @@ -144,8 +142,6 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis @Inject private ConfigManager configManager; - private boolean shiftPressed = false; - @Provides BankTagsConfig getConfig(ConfigManager configManager) { @@ -186,7 +182,6 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis public void startUp() { cleanConfig(); - keyManager.registerKeyListener(this); mouseManager.registerMouseWheelListener(this); clientThread.invokeLater(tabInterface::init); spriteManager.addSpriteOverrides(TabSprites.values()); @@ -248,12 +243,9 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis @Override public void shutDown() { - keyManager.unregisterKeyListener(this); mouseManager.unregisterMouseWheelListener(this); clientThread.invokeLater(tabInterface::destroy); spriteManager.removeSpriteOverrides(TabSprites.values()); - - shiftPressed = false; } @Subscribe @@ -467,6 +459,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis @Subscribe public void onDraggingWidgetChanged(DraggingWidgetChanged event) { + final boolean shiftPressed = client.isKeyPressed(KeyCode.KC_SHIFT); tabInterface.handleDrag(event.isDraggingWidget(), shiftPressed); } @@ -479,42 +472,10 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis } } - @Subscribe - public void onFocusChanged(FocusChanged event) - { - if (!event.isFocused()) - { - shiftPressed = false; - } - } - @Override public MouseWheelEvent mouseWheelMoved(MouseWheelEvent event) { tabInterface.handleWheel(event); return event; } - - @Override - public void keyTyped(KeyEvent e) - { - } - - @Override - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_SHIFT) - { - shiftPressed = true; - } - } - - @Override - public void keyReleased(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_SHIFT) - { - shiftPressed = false; - } - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerInputListener.java deleted file mode 100644 index a097d47d29..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerInputListener.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018, TheLonelyDev - * Copyright (c) 2018, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.groundmarkers; - -import java.awt.event.KeyEvent; -import javax.inject.Inject; -import net.runelite.client.input.KeyListener; - -public class GroundMarkerInputListener implements KeyListener -{ - private static final int HOTKEY = KeyEvent.VK_SHIFT; - - private final GroundMarkerPlugin plugin; - - @Inject - private GroundMarkerInputListener(GroundMarkerPlugin plugin) - { - this.plugin = plugin; - } - - @Override - public void keyTyped(KeyEvent e) - { - - } - - @Override - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == HOTKEY) - { - plugin.setHotKeyPressed(true); - } - } - - @Override - public void keyReleased(KeyEvent e) - { - if (e.getKeyCode() == HOTKEY) - { - plugin.setHotKeyPressed(false); - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java index af3dae8f87..e0f37dbb4a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java @@ -38,16 +38,15 @@ import java.util.stream.Collectors; import javax.inject.Inject; import lombok.AccessLevel; import lombok.Getter; -import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; +import net.runelite.api.KeyCode; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.Tile; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuOptionClicked; @@ -74,10 +73,6 @@ public class GroundMarkerPlugin extends Plugin private static final Gson GSON = new Gson(); - @Getter(AccessLevel.PACKAGE) - @Setter(AccessLevel.PACKAGE) - private boolean hotKeyPressed; - @Getter(AccessLevel.PACKAGE) private final List points = new ArrayList<>(); @@ -87,9 +82,6 @@ public class GroundMarkerPlugin extends Plugin @Inject private GroundMarkerConfig config; - @Inject - private GroundMarkerInputListener inputListener; - @Inject private ConfigManager configManager; @@ -195,18 +187,10 @@ public class GroundMarkerPlugin extends Plugin loadPoints(); } - @Subscribe - public void onFocusChanged(FocusChanged focusChanged) - { - if (!focusChanged.isFocused()) - { - hotKeyPressed = false; - } - } - @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { + final boolean hotKeyPressed = client.isKeyPressed(KeyCode.KC_SHIFT); if (hotKeyPressed && event.getOption().equals(WALK_HERE)) { final Tile selectedSceneTile = client.getSelectedSceneTile(); @@ -254,7 +238,6 @@ public class GroundMarkerPlugin extends Plugin { overlayManager.add(overlay); overlayManager.add(minimapOverlay); - keyManager.registerKeyListener(inputListener); loadPoints(); } @@ -263,7 +246,6 @@ public class GroundMarkerPlugin extends Plugin { overlayManager.remove(overlay); overlayManager.remove(minimapOverlay); - keyManager.unregisterKeyListener(inputListener); points.clear(); } 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 23cd79d44e..1ea8ca1383 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 @@ -42,15 +42,14 @@ import java.util.function.Predicate; import java.util.function.Supplier; import javax.inject.Inject; import lombok.Getter; -import lombok.Setter; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.ItemComposition; +import net.runelite.api.KeyCode; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.NPC; import net.runelite.api.events.ClientTick; -import net.runelite.api.events.FocusChanged; import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuOpened; import net.runelite.api.events.MenuOptionClicked; @@ -131,9 +130,6 @@ public class MenuEntrySwapperPlugin extends Plugin @Inject private MenuEntrySwapperConfig config; - @Inject - private ShiftClickInputListener inputListener; - @Inject private ConfigManager configManager; @@ -149,9 +145,6 @@ public class MenuEntrySwapperPlugin extends Plugin @Getter private boolean configuringShiftClick = false; - @Setter - private boolean shiftModifier = false; - private final Multimap swaps = LinkedHashMultimap.create(); private final ArrayListMultimap optionIndexes = ArrayListMultimap.create(); @@ -299,39 +292,39 @@ public class MenuEntrySwapperPlugin extends Plugin swap("pick", "pick-lots", config::swapPick); - swap("view offer", "abort offer", () -> shiftModifier && config.swapGEAbort()); + swap("view offer", "abort offer", () -> shiftModifier() && config.swapGEAbort()); - swap("cast", "npc contact", "honest jimmy", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "bert the sandman", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "advisor ghrim", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "dark mage", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "lanthus", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "turael", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "mazchna", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "vannaka", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "chaeldar", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "nieve", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "steve", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "duradel", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "krystilia", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "konar", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "murphy", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "cyrisus", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "smoggy", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "ginea", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "watson", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "barbarian guard", () -> shiftModifier && config.swapNpcContact()); - swap("cast", "npc contact", "random", () -> shiftModifier && config.swapNpcContact()); + swap("cast", "npc contact", "honest jimmy", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "bert the sandman", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "advisor ghrim", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "dark mage", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "lanthus", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "turael", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "mazchna", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "vannaka", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "chaeldar", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "nieve", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "steve", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "duradel", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "krystilia", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "konar", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "murphy", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "cyrisus", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "smoggy", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "ginea", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "watson", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "barbarian guard", () -> shiftModifier() && config.swapNpcContact()); + swap("cast", "npc contact", "random", () -> shiftModifier() && config.swapNpcContact()); - swap("value", "buy 1", () -> shiftModifier && config.shopBuy() == BuyMode.BUY_1); - swap("value", "buy 5", () -> shiftModifier && config.shopBuy() == BuyMode.BUY_5); - swap("value", "buy 10", () -> shiftModifier && config.shopBuy() == BuyMode.BUY_10); - swap("value", "buy 50", () -> shiftModifier && config.shopBuy() == BuyMode.BUY_50); + swap("value", "buy 1", () -> shiftModifier() && config.shopBuy() == BuyMode.BUY_1); + swap("value", "buy 5", () -> shiftModifier() && config.shopBuy() == BuyMode.BUY_5); + swap("value", "buy 10", () -> shiftModifier() && config.shopBuy() == BuyMode.BUY_10); + swap("value", "buy 50", () -> shiftModifier() && config.shopBuy() == BuyMode.BUY_50); - swap("value", "sell 1", () -> shiftModifier && config.shopSell() == SellMode.SELL_1); - swap("value", "sell 5", () -> shiftModifier && config.shopSell() == SellMode.SELL_5); - swap("value", "sell 10", () -> shiftModifier && config.shopSell() == SellMode.SELL_10); - swap("value", "sell 50", () -> shiftModifier && config.shopSell() == SellMode.SELL_50); + swap("value", "sell 1", () -> shiftModifier() && config.shopSell() == SellMode.SELL_1); + swap("value", "sell 5", () -> shiftModifier() && config.shopSell() == SellMode.SELL_5); + swap("value", "sell 10", () -> shiftModifier() && config.shopSell() == SellMode.SELL_10); + swap("value", "sell 50", () -> shiftModifier() && config.shopSell() == SellMode.SELL_50); swap("wear", "rub", config::swapTeleportItem); swap("wear", "teleport", config::swapTeleportItem); @@ -382,8 +375,8 @@ public class MenuEntrySwapperPlugin extends Plugin private void swapTeleport(String option, String swappedOption) { - swap("cast", option, swappedOption, () -> shiftModifier && config.swapTeleportSpell()); - swap(swappedOption, option, "cast", () -> shiftModifier && config.swapTeleportSpell()); + swap("cast", option, swappedOption, () -> shiftModifier() && config.swapTeleportSpell()); + swap(swappedOption, option, "cast", () -> shiftModifier() && config.swapTeleportSpell()); } @Subscribe @@ -438,7 +431,6 @@ public class MenuEntrySwapperPlugin extends Plugin private void enableCustomization() { - keyManager.registerKeyListener(inputListener); refreshShiftClickCustomizationMenus(); // set shift click action index on the item compositions clientThread.invoke(this::resetItemCompositionCache); @@ -446,7 +438,6 @@ public class MenuEntrySwapperPlugin extends Plugin private void disableCustomization() { - keyManager.unregisterKeyListener(inputListener); removeShiftClickCustomizationMenus(); configuringShiftClick = false; // flush item compositions to reset the shift click action index @@ -536,7 +527,7 @@ public class MenuEntrySwapperPlugin extends Plugin // Swap to shift-click deposit behavior // Deposit- op 1 is the current withdraw amount 1/5/10/x for deposit box interface // Deposit- op 2 is the current withdraw amount 1/5/10/x for bank interface - if (shiftModifier && config.bankDepositShiftClick() != ShiftDepositMode.OFF + if (shiftModifier() && config.bankDepositShiftClick() != ShiftDepositMode.OFF && menuEntryAdded.getType() == MenuAction.CC_OP.getId() && (menuEntryAdded.getIdentifier() == 2 || menuEntryAdded.getIdentifier() == 1) && menuEntryAdded.getOption().startsWith("Deposit-")) { @@ -548,7 +539,7 @@ public class MenuEntrySwapperPlugin extends Plugin // Swap to shift-click withdraw behavior // Deposit- op 1 is the current withdraw amount 1/5/10/x - if (shiftModifier && config.bankWithdrawShiftClick() != ShiftWithdrawMode.OFF + if (shiftModifier() && config.bankWithdrawShiftClick() != ShiftWithdrawMode.OFF && menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getIdentifier() == 1 && menuEntryAdded.getOption().startsWith("Withdraw-")) { @@ -645,7 +636,7 @@ public class MenuEntrySwapperPlugin extends Plugin return; } - if (shiftModifier && (menuAction == MenuAction.ITEM_FIRST_OPTION + if (shiftModifier() && (menuAction == MenuAction.ITEM_FIRST_OPTION || menuAction == MenuAction.ITEM_SECOND_OPTION || menuAction == MenuAction.ITEM_THIRD_OPTION || menuAction == MenuAction.ITEM_FOURTH_OPTION @@ -730,15 +721,6 @@ public class MenuEntrySwapperPlugin extends Plugin } } - @Subscribe - public void onFocusChanged(FocusChanged event) - { - if (!event.isFocused()) - { - shiftModifier = false; - } - } - private boolean swap(String option, String target, int index, boolean strict) { MenuEntry[] menuEntries = client.getMenuEntries(); @@ -853,4 +835,9 @@ public class MenuEntrySwapperPlugin extends Plugin menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE); } } + + private boolean shiftModifier() + { + return client.isKeyPressed(KeyCode.KC_SHIFT); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java deleted file mode 100644 index f7dde77e00..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018, Kamiel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.menuentryswapper; - -import java.awt.event.KeyEvent; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.client.callback.ClientThread; -import net.runelite.client.input.KeyListener; - -public class ShiftClickInputListener implements KeyListener -{ - @Inject - private ClientThread clientThread; - - @Inject - private Client client; - - @Inject - private MenuEntrySwapperPlugin plugin; - - @Override - public void keyTyped(KeyEvent event) - { - - } - - @Override - public void keyPressed(KeyEvent event) - { - if (event.getKeyCode() == KeyEvent.VK_SHIFT) - { - plugin.setShiftModifier(true); - } - } - - @Override - public void keyReleased(KeyEvent event) - { - if (event.getKeyCode() == KeyEvent.VK_SHIFT) - { - plugin.setShiftModifier(false); - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsInput.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsInput.java deleted file mode 100644 index a744208264..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsInput.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2018, Seth - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.npchighlight; - -import java.awt.event.KeyEvent; -import javax.inject.Inject; -import net.runelite.client.input.KeyListener; - -public class NpcIndicatorsInput implements KeyListener -{ - private static final int HOTKEY = KeyEvent.VK_SHIFT; - - @Inject - private NpcIndicatorsPlugin plugin; - - @Override - public void keyTyped(KeyEvent e) - { - - } - - @Override - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == HOTKEY) - { - plugin.setHotKeyPressed(true); - } - } - - @Override - public void keyReleased(KeyEvent e) - { - if (e.getKeyCode() == HOTKEY) - { - plugin.setHotKeyPressed(false); - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 77abdd41f3..107bb58cbd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -41,18 +41,17 @@ import java.util.Set; import javax.inject.Inject; import lombok.AccessLevel; import lombok.Getter; -import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.GraphicID; import net.runelite.api.GraphicsObject; +import net.runelite.api.KeyCode; import net.runelite.api.MenuAction; import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET; import net.runelite.api.MenuEntry; import net.runelite.api.NPC; import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.GraphicsObjectCreated; @@ -105,18 +104,12 @@ public class NpcIndicatorsPlugin extends Plugin @Inject private NpcMinimapOverlay npcMinimapOverlay; - @Inject - private NpcIndicatorsInput inputListener; - @Inject private KeyManager keyManager; @Inject private ClientThread clientThread; - @Setter(AccessLevel.PACKAGE) - private boolean hotKeyPressed = false; - /** * NPCs to highlight */ @@ -191,7 +184,6 @@ public class NpcIndicatorsPlugin extends Plugin { overlayManager.add(npcSceneOverlay); overlayManager.add(npcMinimapOverlay); - keyManager.registerKeyListener(inputListener); highlights = getHighlights(); clientThread.invoke(() -> { @@ -212,7 +204,6 @@ public class NpcIndicatorsPlugin extends Plugin teleportGraphicsObjectSpawnedThisTick.clear(); npcTags.clear(); highlightedNpcs.clear(); - keyManager.unregisterKeyListener(inputListener); } @Subscribe @@ -241,15 +232,6 @@ public class NpcIndicatorsPlugin extends Plugin rebuildAllNpcs(); } - @Subscribe - public void onFocusChanged(FocusChanged focusChanged) - { - if (!focusChanged.isFocused()) - { - hotKeyPressed = false; - } - } - @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { @@ -286,7 +268,7 @@ public class NpcIndicatorsPlugin extends Plugin client.setMenuEntries(menuEntries); } } - else if (hotKeyPressed && menuAction == MenuAction.EXAMINE_NPC) + else if (menuAction == MenuAction.EXAMINE_NPC && client.isKeyPressed(KeyCode.KC_SHIFT)) { // Add tag option MenuEntry[] menuEntries = client.getMenuEntries(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java index 8c9e326310..dc028cb0c0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java @@ -30,7 +30,6 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.inject.Provides; import java.awt.Color; -import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -49,6 +48,7 @@ import net.runelite.api.DecorativeObject; import net.runelite.api.GameObject; import net.runelite.api.GameState; import net.runelite.api.GroundObject; +import net.runelite.api.KeyCode; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.ObjectComposition; @@ -59,7 +59,6 @@ import net.runelite.api.WallObject; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.DecorativeObjectDespawned; import net.runelite.api.events.DecorativeObjectSpawned; -import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameObjectDespawned; import net.runelite.api.events.GameObjectSpawned; import net.runelite.api.events.GameStateChanged; @@ -72,7 +71,6 @@ import net.runelite.api.events.WallObjectDespawned; import net.runelite.api.events.WallObjectSpawned; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @@ -85,7 +83,7 @@ import net.runelite.client.ui.overlay.OverlayManager; enabledByDefault = false ) @Slf4j -public class ObjectIndicatorsPlugin extends Plugin implements KeyListener +public class ObjectIndicatorsPlugin extends Plugin { private static final String CONFIG_GROUP = "objectindicators"; private static final String MARK = "Mark object"; @@ -95,7 +93,6 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener @Getter(AccessLevel.PACKAGE) private final List objects = new ArrayList<>(); private final Map> points = new HashMap<>(); - private boolean hotKeyPressed; @Inject private Client client; @@ -125,50 +122,14 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener protected void startUp() { overlayManager.add(overlay); - keyManager.registerKeyListener(this); } @Override protected void shutDown() { overlayManager.remove(overlay); - keyManager.unregisterKeyListener(this); points.clear(); objects.clear(); - hotKeyPressed = false; - } - - @Override - public void keyTyped(KeyEvent e) - { - - } - - @Override - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_SHIFT) - { - hotKeyPressed = true; - } - } - - @Override - public void keyReleased(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_SHIFT) - { - hotKeyPressed = false; - } - } - - @Subscribe - public void onFocusChanged(final FocusChanged event) - { - if (!event.isFocused()) - { - hotKeyPressed = false; - } } @Subscribe @@ -258,7 +219,7 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (!hotKeyPressed || event.getType() != MenuAction.EXAMINE_OBJECT.getId()) + if (event.getType() != MenuAction.EXAMINE_OBJECT.getId() || !client.isKeyPressed(KeyCode.KC_SHIFT)) { return; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java index 1f94f976ee..80b97dd61c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java @@ -27,7 +27,6 @@ package net.runelite.client.plugins.party; import com.google.inject.Binder; import com.google.inject.Provides; import java.awt.Color; -import java.awt.event.KeyEvent; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collections; @@ -42,6 +41,7 @@ import lombok.Getter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GameState; +import net.runelite.api.KeyCode; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.Skill; @@ -49,7 +49,6 @@ import net.runelite.api.SoundEffectID; import net.runelite.api.Tile; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.CommandExecuted; -import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.MenuOptionClicked; import net.runelite.client.callback.ClientThread; @@ -61,7 +60,6 @@ import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.OverlayMenuClicked; import net.runelite.client.events.PartyChanged; -import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @@ -86,7 +84,7 @@ import net.runelite.http.api.ws.messages.party.UserSync; name = "Party", description = "Shows useful information about current party" ) -public class PartyPlugin extends Plugin implements KeyListener +public class PartyPlugin extends Plugin { @Inject private Client client; @@ -135,7 +133,7 @@ public class PartyPlugin extends Plugin implements KeyListener private final List pendingTilePings = Collections.synchronizedList(new ArrayList<>()); private int lastHp, lastPray; - private boolean hotkeyDown, doSync; + private boolean doSync; private boolean sendAlert; @Override @@ -152,7 +150,6 @@ public class PartyPlugin extends Plugin implements KeyListener wsClient.registerMessage(SkillUpdate.class); wsClient.registerMessage(TilePing.class); wsClient.registerMessage(LocationUpdate.class); - keyManager.registerKeyListener(this); doSync = true; // Delay sync so eventbus can process correctly. } @@ -167,8 +164,6 @@ public class PartyPlugin extends Plugin implements KeyListener wsClient.unregisterMessage(SkillUpdate.class); wsClient.unregisterMessage(TilePing.class); wsClient.unregisterMessage(LocationUpdate.class); - keyManager.unregisterKeyListener(this); - hotkeyDown = false; doSync = false; sendAlert = false; } @@ -208,7 +203,7 @@ public class PartyPlugin extends Plugin implements KeyListener @Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { - if (!hotkeyDown || client.isMenuOpen() || party.getMembers().isEmpty() || !config.pings()) + if (!client.isKeyPressed(KeyCode.KC_SHIFT) || client.isMenuOpen() || party.getMembers().isEmpty() || !config.pings()) { return; } @@ -503,39 +498,6 @@ public class PartyPlugin extends Plugin implements KeyListener }); } - @Subscribe - public void onFocusChanged(FocusChanged event) - { - if (!event.isFocused()) - { - hotkeyDown = false; - } - } - - @Override - public void keyTyped(KeyEvent keyEvent) - { - - } - - @Override - public void keyPressed(KeyEvent keyEvent) - { - if (keyEvent.getKeyCode() == KeyEvent.VK_SHIFT) - { - hotkeyDown = true; - } - } - - @Override - public void keyReleased(KeyEvent keyEvent) - { - if (keyEvent.getKeyCode() == KeyEvent.VK_SHIFT) - { - hotkeyDown = false; - } - } - private void sendInstructionMessage() { final String helpMessage = new ChatMessageBuilder() diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java index b1f77c708a..fadbf0a28b 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java @@ -30,6 +30,7 @@ import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; import net.runelite.api.Client; import net.runelite.api.GameState; +import net.runelite.api.KeyCode; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.events.ClientTick; @@ -224,7 +225,7 @@ public class MenuEntrySwapperPluginTest public void testTeleport() { when(config.swapTeleportSpell()).thenReturn(true); - menuEntrySwapperPlugin.setShiftModifier(true); + when(client.isKeyPressed(KeyCode.KC_SHIFT)).thenReturn(true); // Cast -> Grand Exchange entries = new MenuEntry[]{ @@ -307,7 +308,7 @@ public class MenuEntrySwapperPluginTest public void testShiftWithdraw() { when(config.bankDepositShiftClick()).thenReturn(ShiftDepositMode.EXTRA_OP); - menuEntrySwapperPlugin.setShiftModifier(true); + when(client.isKeyPressed(KeyCode.KC_SHIFT)).thenReturn(true); entries = new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), @@ -338,7 +339,7 @@ public class MenuEntrySwapperPluginTest public void testShiftDeposit() { when(config.bankDepositShiftClick()).thenReturn(ShiftDepositMode.DEPOSIT_ALL); - menuEntrySwapperPlugin.setShiftModifier(true); + when(client.isKeyPressed(KeyCode.KC_SHIFT)).thenReturn(true); entries = new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL),