Remove always true if statement and don't always update buy/sell swaps

This commit is contained in:
Lucwousin
2019-09-18 17:22:58 +02:00
parent f928454f3e
commit 10b51778b7

View File

@@ -309,6 +309,9 @@ public class MenuEntrySwapperPlugin extends Plugin
addSwaps(); addSwaps();
loadConstructionItems(); loadConstructionItems();
loadCustomSwaps(config.customSwaps(), customSwaps); loadCustomSwaps(config.customSwaps(), customSwaps);
updateBuySellEntries();
addBuySellEntries();
keyManager.registerKeyListener(ctrlHotkey); keyManager.registerKeyListener(ctrlHotkey);
keyManager.registerKeyListener(hotkey); keyManager.registerKeyListener(hotkey);
if (client.getGameState() == GameState.LOGGED_IN) if (client.getGameState() == GameState.LOGGED_IN)
@@ -324,6 +327,8 @@ public class MenuEntrySwapperPlugin extends Plugin
loadCustomSwaps("", customSwaps); // Removes all custom swaps loadCustomSwaps("", customSwaps); // Removes all custom swaps
removeSwaps(); removeSwaps();
removeBuySellEntries();
keyManager.unregisterKeyListener(ctrlHotkey); keyManager.unregisterKeyListener(ctrlHotkey);
keyManager.unregisterKeyListener(hotkey); keyManager.unregisterKeyListener(hotkey);
if (client.getGameState() == GameState.LOGGED_IN) if (client.getGameState() == GameState.LOGGED_IN)
@@ -363,36 +368,42 @@ public class MenuEntrySwapperPlugin extends Plugin
addSwaps(); addSwaps();
loadConstructionItems(); loadConstructionItems();
if (!CONFIG_GROUP.equals(event.getGroup())) switch (event.getKey())
{ {
if (event.getKey().equals("customSwaps")) case "customSwaps":
{
loadCustomSwaps(this.configCustomSwaps, 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) removeBuySellEntries();
{ updateBuySellEntries();
setCastOptions(true); addBuySellEntries();
} return;
else
{
resetCastOptions();
}
}
else if ((event.getKey().equals("hideCastCoX") || event.getKey().equals("hideCastIgnoredCoX")))
{
if (this.hideCastCoX)
{
setCastOptions(true);
}
else
{
resetCastOptions();
}
} }
} }
@@ -751,8 +762,6 @@ public class MenuEntrySwapperPlugin extends Plugin
menuManager.addSwap(a, b); menuManager.addSwap(a, b);
} }
addBuySellEntries();
if (this.getWithdrawOne) if (this.getWithdrawOne)
{ {
Text.fromCSV(this.getWithdrawOneItems).forEach(item -> Text.fromCSV(this.getWithdrawOneItems).forEach(item ->
@@ -1206,8 +1215,6 @@ public class MenuEntrySwapperPlugin extends Plugin
dePrioIter.remove(); dePrioIter.remove();
}); });
removeBuySellEntries();
Text.fromCSV(this.getWithdrawOneItems).forEach(item -> Text.fromCSV(this.getWithdrawOneItems).forEach(item ->
{ {
menuManager.removePriorityEntry(newBankComparableEntry("Withdraw-1", item)); menuManager.removePriorityEntry(newBankComparableEntry("Withdraw-1", item));
@@ -1717,8 +1724,6 @@ public class MenuEntrySwapperPlugin extends Plugin
this.swapWildernessLever = config.swapWildernessLever(); this.swapWildernessLever = config.swapWildernessLever();
this.swapHouseAd = config.swapHouseAd(); this.swapHouseAd = config.swapHouseAd();
this.swapHouseAdMode = config.swapHouseAdMode(); this.swapHouseAdMode = config.swapHouseAdMode();
updateBuySellEntries();
} }
private void addBuySellEntries() private void addBuySellEntries()