Fix rc fill pouch from bank (#336)
This commit is contained in:
@@ -223,6 +223,15 @@ public class MenuManager
|
||||
|
||||
if (foundSwap != null)
|
||||
{
|
||||
if (swapTarget.getType() != -1 && newestEntry.getType() != foundSwap.getType())
|
||||
{
|
||||
int newType = foundSwap.getType();
|
||||
|
||||
foundSwap.setType(newestEntry.getType());
|
||||
|
||||
newestEntry.setType(newType);
|
||||
}
|
||||
|
||||
// Swap
|
||||
int index = copy.indexOf(foundSwap);
|
||||
int newIndex = copy.indexOf(newestEntry);
|
||||
@@ -512,6 +521,56 @@ public class MenuManager
|
||||
swaps.put(swapFrom, swapTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the map of swaps - Non-strict option/target, but with type & id
|
||||
* ID's of -1 are ignored in matches()!
|
||||
*/
|
||||
public void addSwap(String option, String target, int id, int type, String option2, String target2, int id2, int type2)
|
||||
{
|
||||
option = Text.standardize(option);
|
||||
target = Text.standardize(target);
|
||||
|
||||
option2 = Text.standardize(option2);
|
||||
target2 = Text.standardize(target2);
|
||||
|
||||
AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target, id, type, false, false);
|
||||
AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2, id2, type2, false, false);
|
||||
|
||||
if (swapTo.equals(swapFrom))
|
||||
{
|
||||
log.warn("You shouldn't try swapping an entry for itself");
|
||||
return;
|
||||
}
|
||||
|
||||
swaps.put(swapFrom, swapTo);
|
||||
}
|
||||
|
||||
public void removeSwap(String option, String target, int id, int type, String option2, String target2, int id2, int type2)
|
||||
{
|
||||
option = Text.standardize(option);
|
||||
target = Text.standardize(target);
|
||||
|
||||
option2 = Text.standardize(option2);
|
||||
target2 = Text.standardize(target2);
|
||||
|
||||
AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target, id, type, false, false);
|
||||
AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2, id2, type2, false, false);
|
||||
|
||||
Set<AbstractMenuEntry> toRemove = new HashSet<>();
|
||||
for (Map.Entry<AbstractMenuEntry, AbstractMenuEntry> e : swaps.entrySet())
|
||||
{
|
||||
if (e.getKey().equals(swapFrom) && e.getValue().equals(swapTo))
|
||||
{
|
||||
toRemove.add(e.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
for (AbstractMenuEntry entry : toRemove)
|
||||
{
|
||||
swaps.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSwap(String option, String target, String option2, String target2)
|
||||
{
|
||||
option = Text.standardize(option);
|
||||
|
||||
@@ -228,4 +228,14 @@ public interface RunecraftConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "essPouch",
|
||||
name = "Swap essence pouch",
|
||||
description = "Makes essence pouch left-click fill in bank"
|
||||
)
|
||||
default boolean essPouch()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
@@ -117,6 +118,9 @@ public class RunecraftPlugin extends Plugin
|
||||
@Inject
|
||||
private Notifier notifier;
|
||||
|
||||
@Inject
|
||||
private MenuManager menuManager;
|
||||
|
||||
@Provides
|
||||
RunecraftConfig getConfig(ConfigManager configManager)
|
||||
{
|
||||
@@ -144,6 +148,23 @@ public class RunecraftPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (!event.getGroup().equals("runecraft"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey().equals("essPouch"))
|
||||
{
|
||||
if (config.essPouch())
|
||||
{
|
||||
menuManager.addSwap("deposit", "pouch", 2, 57, "fill", "pouch", 9, 1007);
|
||||
}
|
||||
else
|
||||
{
|
||||
menuManager.removeSwap("deposit", "pouch", 2, 57, "fill", "pouch", 9, 1007);
|
||||
}
|
||||
}
|
||||
|
||||
abyssOverlay.updateConfig();
|
||||
}
|
||||
|
||||
@@ -172,33 +193,8 @@ public class RunecraftPlugin extends Plugin
|
||||
final String option = Text.removeTags(entry.getOption()).toLowerCase();
|
||||
final String target = Text.removeTags(entry.getTarget()).toLowerCase();
|
||||
final int id = entry.getIdentifier();
|
||||
final int type = entry.getType();
|
||||
|
||||
if (target.contains("pouch") && !target.startsWith("rune"))
|
||||
{
|
||||
if (option.contains("deposit") && type == 57 && id == 2) //swap pouches based on empty/full and in ban
|
||||
{
|
||||
swap(client, "fill", option, target);
|
||||
swap(client, "cancel", option, "", target);
|
||||
}
|
||||
else if (option.equals("fill") && id != 9)
|
||||
{
|
||||
swap(client, "empty", option, target); //Due to RuneLite issues the "Deposit" menutext will always show even though it is on fill
|
||||
}
|
||||
}
|
||||
if (target.contains("ring of dueling") && option.contains("withdraw"))//withdraw-1 ring of dueling
|
||||
{
|
||||
swap(client, "withdraw-1", option, target);
|
||||
}
|
||||
else if (target.contains("binding necklace") && option.contains("withdraw")) //withdraw-1 binding necklace
|
||||
{
|
||||
swap(client, "withdraw-1", option, target);
|
||||
}
|
||||
else if (target.contains("stamina") && option.contains("withdraw"))
|
||||
{ //withdraw-1 stam
|
||||
swap(client, "withdraw-1", option, target);
|
||||
}
|
||||
else if (target.contains("ring of dueling") && option.contains("remove"))
|
||||
if (target.contains("ring of dueling") && option.contains("remove"))
|
||||
{
|
||||
if (client.getLocalPlayer().getWorldLocation().getRegionID() != 10315)
|
||||
{ //changes duel ring teleport options based on location
|
||||
|
||||
Reference in New Issue
Block a user