From 10b51778b7e6064b77914e523c6aef12fb6b2248 Mon Sep 17 00:00:00 2001 From: Lucwousin Date: Wed, 18 Sep 2019 17:22:58 +0200 Subject: [PATCH] Remove always true if statement and don't always update buy/sell swaps --- .../MenuEntrySwapperPlugin.java | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 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 d19fd1829a..4c841f27fc 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 @@ -309,6 +309,9 @@ public class MenuEntrySwapperPlugin extends Plugin addSwaps(); loadConstructionItems(); loadCustomSwaps(config.customSwaps(), customSwaps); + updateBuySellEntries(); + addBuySellEntries(); + keyManager.registerKeyListener(ctrlHotkey); keyManager.registerKeyListener(hotkey); if (client.getGameState() == GameState.LOGGED_IN) @@ -324,6 +327,8 @@ public class MenuEntrySwapperPlugin extends Plugin loadCustomSwaps("", customSwaps); // Removes all custom swaps removeSwaps(); + removeBuySellEntries(); + keyManager.unregisterKeyListener(ctrlHotkey); keyManager.unregisterKeyListener(hotkey); if (client.getGameState() == GameState.LOGGED_IN) @@ -363,36 +368,42 @@ public class MenuEntrySwapperPlugin extends Plugin addSwaps(); loadConstructionItems(); - if (!CONFIG_GROUP.equals(event.getGroup())) + switch (event.getKey()) { - if (event.getKey().equals("customSwaps")) - { + case "customSwaps": loadCustomSwaps(this.configCustomSwaps, customSwaps); - } + return; + case "hideCastToB": + case "hideCastIgnoredToB": + if (this.hideCastToB) + { + setCastOptions(true); + } + else + { + resetCastOptions(); + } + return; + case "hideCastCoX": + case "hideCastIgnoredCoX": + if (this.hideCastCoX) + { + setCastOptions(true); + } + else + { + resetCastOptions(); + } + return; } - else if ((event.getKey().equals("hideCastToB") || event.getKey().equals("hideCastIgnoredToB"))) + if (event.getKey().startsWith("swapSell") || event.getKey().startsWith("swapBuy") || + (event.getKey().startsWith("sell") || event.getKey().startsWith("buy")) && event.getKey().endsWith("Items")) { - if (this.hideCastToB) - { - setCastOptions(true); - } - else - { - resetCastOptions(); - } - } - - else if ((event.getKey().equals("hideCastCoX") || event.getKey().equals("hideCastIgnoredCoX"))) - { - if (this.hideCastCoX) - { - setCastOptions(true); - } - else - { - resetCastOptions(); - } + removeBuySellEntries(); + updateBuySellEntries(); + addBuySellEntries(); + return; } } @@ -751,8 +762,6 @@ public class MenuEntrySwapperPlugin extends Plugin menuManager.addSwap(a, b); } - addBuySellEntries(); - if (this.getWithdrawOne) { Text.fromCSV(this.getWithdrawOneItems).forEach(item -> @@ -1206,8 +1215,6 @@ public class MenuEntrySwapperPlugin extends Plugin dePrioIter.remove(); }); - removeBuySellEntries(); - Text.fromCSV(this.getWithdrawOneItems).forEach(item -> { menuManager.removePriorityEntry(newBankComparableEntry("Withdraw-1", item)); @@ -1717,8 +1724,6 @@ public class MenuEntrySwapperPlugin extends Plugin this.swapWildernessLever = config.swapWildernessLever(); this.swapHouseAd = config.swapHouseAd(); this.swapHouseAdMode = config.swapHouseAdMode(); - - updateBuySellEntries(); } private void addBuySellEntries()