Cleanup withdraw menu entry swaps
This commit is contained in:
@@ -686,7 +686,9 @@ public enum Varbits
|
||||
/**
|
||||
* 1 is true, 0 is false.
|
||||
*/
|
||||
GAUNTLET_ENTERED(9178);
|
||||
GAUNTLET_ENTERED(9178),
|
||||
|
||||
WITHDRAW_X_AMOUNT(3960);
|
||||
|
||||
/**
|
||||
* The raw varbit ID.
|
||||
|
||||
-14
@@ -152,20 +152,6 @@ public interface MenuEntrySwapperConfig extends Config
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "withdrawXAmount",
|
||||
name = "Amount",
|
||||
description = "",
|
||||
position = 7,
|
||||
group = "Banking",
|
||||
hidden = true,
|
||||
unhide = "withdrawX"
|
||||
)
|
||||
default String getWithdrawXAmount()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "withdrawXItems",
|
||||
name = "Items",
|
||||
|
||||
+109
-94
@@ -58,6 +58,7 @@ import net.runelite.api.NPC;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Varbits;
|
||||
import static net.runelite.api.Varbits.BUILDING_MODE;
|
||||
import static net.runelite.api.Varbits.WITHDRAW_X_AMOUNT;
|
||||
import net.runelite.api.WorldType;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.ClientTick;
|
||||
@@ -86,6 +87,7 @@ import net.runelite.client.plugins.menuentryswapper.comparables.BankComparableEn
|
||||
import net.runelite.client.plugins.menuentryswapper.comparables.EquipmentComparableEntry;
|
||||
import net.runelite.client.plugins.menuentryswapper.comparables.InventoryComparableEntry;
|
||||
import net.runelite.client.plugins.menuentryswapper.comparables.ShopComparableEntry;
|
||||
import net.runelite.client.plugins.menuentryswapper.comparables.WithdrawComparableEntry;
|
||||
import net.runelite.client.plugins.menuentryswapper.util.BurningAmuletMode;
|
||||
import net.runelite.client.plugins.menuentryswapper.util.CharterOption;
|
||||
import net.runelite.client.plugins.menuentryswapper.util.CombatBraceletMode;
|
||||
@@ -179,6 +181,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
// 1, 5, 10, 50
|
||||
private final AbstractComparableEntry[][] buyEntries = new AbstractComparableEntry[4][];
|
||||
private final AbstractComparableEntry[][] sellEntries = new AbstractComparableEntry[4][];
|
||||
// 1, 5, 10, X, All
|
||||
private final AbstractComparableEntry[][] withdrawEntries = new AbstractComparableEntry[5][];
|
||||
|
||||
private List<String> bankItemNames = new ArrayList<>();
|
||||
private BurningAmuletMode getBurningAmuletMode;
|
||||
@@ -208,12 +212,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
private String configCustomShiftSwaps;
|
||||
private String configCustomSwaps;
|
||||
private String getRemovedObjects;
|
||||
private String getWithdrawAllItems;
|
||||
private String getWithdrawFiveItems;
|
||||
private String getWithdrawOneItems;
|
||||
private String getWithdrawTenItems;
|
||||
private String getWithdrawXAmount;
|
||||
private String getWithdrawXItems;
|
||||
private XericsTalismanMode getXericsTalismanMode;
|
||||
private boolean getBurningAmulet;
|
||||
private boolean getCombatBracelet;
|
||||
@@ -236,11 +234,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
private boolean getSwapSawmill;
|
||||
private boolean getSwapSawmillPlanks;
|
||||
private boolean getSwapTanning;
|
||||
private boolean getWithdrawAll;
|
||||
private boolean getWithdrawFive;
|
||||
private boolean getWithdrawOne;
|
||||
private boolean getWithdrawTen;
|
||||
private boolean getWithdrawX;
|
||||
private boolean getXericsTalisman;
|
||||
private boolean hideBait;
|
||||
private boolean hideCastCoX;
|
||||
@@ -309,9 +302,13 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
addSwaps();
|
||||
loadConstructionItems();
|
||||
loadCustomSwaps(config.customSwaps(), customSwaps);
|
||||
|
||||
updateBuySellEntries();
|
||||
addBuySellEntries();
|
||||
|
||||
updateWithdrawEntries();
|
||||
addWithdrawEntries();
|
||||
|
||||
keyManager.registerKeyListener(ctrlHotkey);
|
||||
keyManager.registerKeyListener(hotkey);
|
||||
if (client.getGameState() == GameState.LOGGED_IN)
|
||||
@@ -328,6 +325,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
loadCustomSwaps("", customSwaps); // Removes all custom swaps
|
||||
removeSwaps();
|
||||
removeBuySellEntries();
|
||||
removeWithdrawEntries();
|
||||
|
||||
keyManager.unregisterKeyListener(ctrlHotkey);
|
||||
keyManager.unregisterKeyListener(hotkey);
|
||||
@@ -403,7 +401,12 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
removeBuySellEntries();
|
||||
updateBuySellEntries();
|
||||
addBuySellEntries();
|
||||
return;
|
||||
}
|
||||
else if (event.getKey().startsWith("withdraw") || event.getKey().startsWith("deposit"))
|
||||
{
|
||||
removeWithdrawEntries();
|
||||
updateWithdrawEntries();
|
||||
addWithdrawEntries();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,6 +423,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
private void onVarbitChanged(VarbitChanged event)
|
||||
{
|
||||
buildingMode = client.getVar(BUILDING_MODE) == 1;
|
||||
WithdrawComparableEntry.setX(client.getVar(WITHDRAW_X_AMOUNT));
|
||||
|
||||
setCastOptions(false);
|
||||
}
|
||||
@@ -756,51 +760,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
menuManager.addSwap(a, b);
|
||||
}
|
||||
|
||||
if (this.getWithdrawOne)
|
||||
{
|
||||
Text.fromCSV(this.getWithdrawOneItems).forEach(item ->
|
||||
{
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Withdraw-1", item)).setPriority(10);
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Deposit-1", item)).setPriority(10);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.getWithdrawFive)
|
||||
{
|
||||
Text.fromCSV(this.getWithdrawFiveItems).forEach(item ->
|
||||
{
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Withdraw-5", item)).setPriority(10);
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Deposit-5", item)).setPriority(10);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.getWithdrawTen)
|
||||
{
|
||||
Text.fromCSV(this.getWithdrawTenItems).forEach(item ->
|
||||
{
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Withdraw-10", item)).setPriority(10);
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Deposit-10", item)).setPriority(10);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.getWithdrawX)
|
||||
{
|
||||
Text.fromCSV(this.getWithdrawXItems).forEach(item ->
|
||||
{
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Withdraw-" + this.getWithdrawXAmount, item)).setPriority(10);
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Deposit-" + this.getWithdrawXAmount, item)).setPriority(10);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.getWithdrawAll)
|
||||
{
|
||||
Text.fromCSV(this.getWithdrawAllItems).forEach(item ->
|
||||
{
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Withdraw-All", item)).setPriority(10);
|
||||
menuManager.addPriorityEntry(newBankComparableEntry("Deposit-All", item)).setPriority(10);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.getSwapTanning)
|
||||
{
|
||||
menuManager.addPriorityEntry("Tan All");
|
||||
@@ -1209,32 +1168,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
dePrioIter.remove();
|
||||
});
|
||||
|
||||
Text.fromCSV(this.getWithdrawOneItems).forEach(item ->
|
||||
{
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Withdraw-1", item));
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Deposit-1", item));
|
||||
});
|
||||
Text.fromCSV(this.getWithdrawFiveItems).forEach(item ->
|
||||
{
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Withdraw-5", item));
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Deposit-5", item));
|
||||
});
|
||||
Text.fromCSV(this.getWithdrawTenItems).forEach(item ->
|
||||
{
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Withdraw-10", item));
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Deposit-10", item));
|
||||
});
|
||||
Text.fromCSV(this.getWithdrawXItems).forEach(item ->
|
||||
{
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Withdraw-" + this.getWithdrawXAmount, item));
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Deposit-" + this.getWithdrawXAmount, item));
|
||||
});
|
||||
Text.fromCSV(this.getWithdrawAllItems).forEach(item ->
|
||||
{
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Withdraw-All", item));
|
||||
menuManager.removePriorityEntry(newBankComparableEntry("Deposit-All", item));
|
||||
});
|
||||
|
||||
menuManager.removePriorityEntry("Activate", "Box trap");
|
||||
menuManager.removePriorityEntry("Assignment");
|
||||
menuManager.removePriorityEntry("Bank");
|
||||
@@ -1643,17 +1576,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
this.getSwapSawmill = config.getSwapSawmill();
|
||||
this.getSwapSawmillPlanks = config.getSwapSawmillPlanks();
|
||||
this.getSwapTanning = config.getSwapTanning();
|
||||
this.getWithdrawAll = config.getWithdrawAll();
|
||||
this.getWithdrawAllItems = config.getWithdrawAllItems();
|
||||
this.getWithdrawFive = config.getWithdrawFive();
|
||||
this.getWithdrawFiveItems = config.getWithdrawFiveItems();
|
||||
this.getWithdrawOne = config.getWithdrawOne();
|
||||
this.getWithdrawOneItems = config.getWithdrawOneItems();
|
||||
this.getWithdrawTen = config.getWithdrawTen();
|
||||
this.getWithdrawTenItems = config.getWithdrawTenItems();
|
||||
this.getWithdrawX = config.getWithdrawX();
|
||||
this.getWithdrawXAmount = config.getWithdrawXAmount();
|
||||
this.getWithdrawXItems = config.getWithdrawXItems();
|
||||
this.getXericsTalisman = config.getXericsTalisman();
|
||||
this.getXericsTalismanMode = config.getXericsTalismanMode();
|
||||
this.hideBait = config.hideBait();
|
||||
@@ -1866,6 +1788,99 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private void addWithdrawEntries()
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (withdrawEntries[i] != null)
|
||||
{
|
||||
for (AbstractComparableEntry entry : withdrawEntries[i])
|
||||
{
|
||||
menuManager.addPriorityEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeWithdrawEntries()
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (withdrawEntries[i] != null)
|
||||
{
|
||||
for (AbstractComparableEntry entry : withdrawEntries[i])
|
||||
{
|
||||
menuManager.removePriorityEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWithdrawEntries()
|
||||
{
|
||||
List<String> tmp;
|
||||
|
||||
if (config.getWithdrawOne())
|
||||
{
|
||||
tmp = Text.fromCSV(config.getWithdrawOneItems());
|
||||
withdrawEntries[0] = new AbstractComparableEntry[tmp.size()];
|
||||
|
||||
WithdrawComparableEntry.populateArray(withdrawEntries[0], tmp, WithdrawComparableEntry.Amount.ONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
withdrawEntries[0] = null;
|
||||
}
|
||||
|
||||
if (config.getWithdrawFive())
|
||||
{
|
||||
tmp = Text.fromCSV(config.getWithdrawFiveItems());
|
||||
withdrawEntries[1] = new AbstractComparableEntry[tmp.size()];
|
||||
|
||||
WithdrawComparableEntry.populateArray(withdrawEntries[1], tmp, WithdrawComparableEntry.Amount.FIVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
withdrawEntries[1] = null;
|
||||
}
|
||||
|
||||
if (config.getWithdrawTen())
|
||||
{
|
||||
tmp = Text.fromCSV(config.getWithdrawTenItems());
|
||||
withdrawEntries[2] = new AbstractComparableEntry[tmp.size()];
|
||||
|
||||
WithdrawComparableEntry.populateArray(withdrawEntries[2], tmp, WithdrawComparableEntry.Amount.TEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
withdrawEntries[2] = null;
|
||||
}
|
||||
|
||||
if (config.getWithdrawX())
|
||||
{
|
||||
tmp = Text.fromCSV(config.getWithdrawXItems());
|
||||
withdrawEntries[3] = new AbstractComparableEntry[tmp.size()];
|
||||
|
||||
WithdrawComparableEntry.populateArray(withdrawEntries[3], tmp, WithdrawComparableEntry.Amount.X);
|
||||
}
|
||||
else
|
||||
{
|
||||
withdrawEntries[3] = null;
|
||||
}
|
||||
|
||||
if (config.getWithdrawAll())
|
||||
{
|
||||
tmp = Text.fromCSV(config.getWithdrawAllItems());
|
||||
withdrawEntries[4] = new AbstractComparableEntry[tmp.size()];
|
||||
|
||||
WithdrawComparableEntry.populateArray(withdrawEntries[4], tmp, WithdrawComparableEntry.Amount.ALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
withdrawEntries[4] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates old custom swaps config
|
||||
* This should be removed after a reasonable amount of time.
|
||||
|
||||
+10
-3
@@ -20,9 +20,7 @@ public class BankComparableEntry extends AbstractComparableEntry
|
||||
|
||||
public boolean matches(MenuEntry entry)
|
||||
{
|
||||
final int groupId = WidgetInfo.TO_GROUP(entry.getParam1());
|
||||
|
||||
if (groupId != WidgetID.BANK_GROUP_ID && groupId != WidgetID.BANK_INVENTORY_GROUP_ID && groupId != WidgetID.GRAND_EXCHANGE_GROUP_ID)
|
||||
if (isNotBankWidget(entry.getParam1()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -34,4 +32,13 @@ public class BankComparableEntry extends AbstractComparableEntry
|
||||
|
||||
return StringUtils.containsIgnoreCase(entry.getOption(), this.getOption()) && Text.standardize(entry.getTarget()).contains(this.getTarget());
|
||||
}
|
||||
|
||||
static boolean isNotBankWidget(int widgetID)
|
||||
{
|
||||
final int groupId = WidgetInfo.TO_GROUP(widgetID);
|
||||
|
||||
return groupId != WidgetID.BANK_GROUP_ID
|
||||
&& groupId != WidgetID.BANK_INVENTORY_GROUP_ID
|
||||
&& groupId != WidgetID.GRAND_EXCHANGE_GROUP_ID;
|
||||
}
|
||||
}
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package net.runelite.client.plugins.menuentryswapper.comparables;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.util.Text;
|
||||
import net.runelite.client.menus.AbstractComparableEntry;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WithdrawComparableEntry extends AbstractComparableEntry
|
||||
{
|
||||
private static String x;
|
||||
|
||||
private final Amount amount;
|
||||
|
||||
private WithdrawComparableEntry(Amount amount, String item)
|
||||
{
|
||||
this.amount = amount;
|
||||
this.setTarget(Text.standardize(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(MenuEntry entry)
|
||||
{
|
||||
if (BankComparableEntry.isNotBankWidget(entry.getParam1()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final String option = entry.getOption();
|
||||
|
||||
if (!option.startsWith("Withdraw") && !option.startsWith("Deposit"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (amount == Amount.X && !option.endsWith(x)
|
||||
|| !option.endsWith(amount.suffix))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Text.standardize(entry.getTarget()).contains(this.getTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
public static void setX(int amount)
|
||||
{
|
||||
x = String.valueOf(amount);
|
||||
}
|
||||
|
||||
public static void populateArray(AbstractComparableEntry[] array, List<String> items, Amount amount)
|
||||
{
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
array[i] = new WithdrawComparableEntry(amount, items.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum Amount
|
||||
{
|
||||
ONE("1"),
|
||||
FIVE("5"),
|
||||
TEN("10"),
|
||||
X(null),
|
||||
ALL("All");
|
||||
|
||||
private String suffix;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user