Use menumanager for easyscape enum config swaps, fix up rc and custom swaps (#351)
* Use menumanager for easyscape enum config swaps, fix up rc * Make essence pouches left click empty in inventory
This commit is contained in:
@@ -223,7 +223,8 @@ public class MenuManager
|
||||
|
||||
if (foundSwap != null)
|
||||
{
|
||||
if (swapTarget.getType() != -1 && newestEntry.getType() != foundSwap.getType())
|
||||
// This is to make things like games necklace and essence pouches show up right
|
||||
if (foundSwap.getType() == MenuAction.EXAMINE_ITEM_BANK_EQ.getId())
|
||||
{
|
||||
int newType = foundSwap.getType();
|
||||
|
||||
@@ -485,9 +486,9 @@ public class MenuManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the map of swaps. - Strict option + target
|
||||
* Adds to the map of swaps.
|
||||
*/
|
||||
public void addSwap(String option, String target, String option2, String target2)
|
||||
public void addSwap(String option, String target, String option2, String target2, boolean strictOption, boolean strictTarget)
|
||||
{
|
||||
option = Text.standardize(option);
|
||||
target = Text.standardize(target);
|
||||
@@ -495,8 +496,8 @@ public class MenuManager
|
||||
option2 = Text.standardize(option2);
|
||||
target2 = Text.standardize(target2);
|
||||
|
||||
AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target);
|
||||
AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2);
|
||||
AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target, -1, -1, strictOption, strictTarget);
|
||||
AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2, -1, -1, strictOption, strictTarget);
|
||||
|
||||
if (swapTo.equals(swapFrom))
|
||||
{
|
||||
@@ -507,6 +508,34 @@ public class MenuManager
|
||||
swaps.put(swapFrom, swapTo);
|
||||
}
|
||||
|
||||
|
||||
public void removeSwap(String option, String target, String option2, String target2, boolean strictOption, boolean strictTarget)
|
||||
{
|
||||
option = Text.standardize(option);
|
||||
target = Text.standardize(target);
|
||||
|
||||
option2 = Text.standardize(option2);
|
||||
target2 = Text.standardize(target2);
|
||||
|
||||
AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target, -1, -1, strictOption, strictTarget);
|
||||
AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2, -1, -1, strictOption, strictTarget);
|
||||
|
||||
removeSwap(swapFrom, swapTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the map of swaps. - Strict option + target
|
||||
*/
|
||||
public void addSwap(String option, String target, String option2, String target2)
|
||||
{
|
||||
addSwap(option, target, option2, target2, false, false);
|
||||
}
|
||||
|
||||
public void removeSwap(String option, String target, String option2, String target2)
|
||||
{
|
||||
removeSwap(option, target, option2, target2, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the map of swaps - Pre-baked Abstract entry
|
||||
*/
|
||||
@@ -571,20 +600,6 @@ public class MenuManager
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSwap(String option, String target, String option2, String target2)
|
||||
{
|
||||
option = Text.standardize(option);
|
||||
target = Text.standardize(target);
|
||||
|
||||
option2 = Text.standardize(option2);
|
||||
target2 = Text.standardize(target2);
|
||||
|
||||
AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target);
|
||||
AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2);
|
||||
|
||||
removeSwap(swapFrom, swapTo);
|
||||
}
|
||||
|
||||
public void removeSwap(AbstractMenuEntry swapFrom, AbstractMenuEntry swapTo)
|
||||
{
|
||||
Set<AbstractMenuEntry> toRemove = new HashSet<>();
|
||||
@@ -601,4 +616,27 @@ public class MenuManager
|
||||
swaps.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all swaps with target
|
||||
*/
|
||||
public void removeSwaps(String withTarget)
|
||||
{
|
||||
withTarget = Text.standardize(withTarget);
|
||||
|
||||
Set<AbstractMenuEntry> toRemove = new HashSet<>();
|
||||
|
||||
for (AbstractMenuEntry e : swaps.keySet())
|
||||
{
|
||||
if (e.getTarget().equals(withTarget))
|
||||
{
|
||||
toRemove.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
for (AbstractMenuEntry entry : toRemove)
|
||||
{
|
||||
swaps.remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.plugins.easyscape.util.DuelingRingMode;
|
||||
import net.runelite.client.plugins.easyscape.util.GamesNecklaceMode;
|
||||
import net.runelite.client.plugins.easyscape.util.GloryMode;
|
||||
import net.runelite.client.plugins.easyscape.util.MaxCapeMode;
|
||||
import net.runelite.client.plugins.easyscape.util.SkillsNecklaceMode;
|
||||
import net.runelite.client.plugins.easyscape.util.NecklaceOfPassageMode;
|
||||
import net.runelite.client.plugins.easyscape.util.DigsitePendantMode;
|
||||
@@ -802,10 +803,34 @@ public interface EasyscapeConfig extends Config
|
||||
default RingOfWealthMode getRingofWealthMode()
|
||||
{
|
||||
return RingOfWealthMode.GRAND_EXCHANGE;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------- //
|
||||
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "swapMax",
|
||||
name = "Swap max cape",
|
||||
description = "Enables swapping max cape options in worn interface",
|
||||
position = 59,
|
||||
group = "Equipment swapper"
|
||||
)
|
||||
default boolean swapMax()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "maxMode",
|
||||
name = "Max cape mode",
|
||||
description = "",
|
||||
position = 60,
|
||||
group = "Equipment swapper"
|
||||
)
|
||||
default MaxCapeMode maxMode()
|
||||
{
|
||||
return MaxCapeMode.CRAFTING_GUILD;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "swapArdougneCape",
|
||||
name = "Swap Ardougne Cape",
|
||||
|
||||
@@ -39,9 +39,11 @@ import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.Player;
|
||||
import static net.runelite.api.Varbits.BUILDING_MODE;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
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.plugins.PluginType;
|
||||
@@ -66,6 +68,9 @@ public class EasyscapePlugin extends Plugin
|
||||
@Inject
|
||||
private EasyscapeConfig config;
|
||||
|
||||
@Inject
|
||||
private MenuManager menuManager;
|
||||
|
||||
@Provides
|
||||
EasyscapeConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
@@ -75,11 +80,13 @@ public class EasyscapePlugin extends Plugin
|
||||
@Override
|
||||
public void startUp()
|
||||
{
|
||||
addSwaps();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown()
|
||||
{
|
||||
removeSwaps();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -379,61 +386,99 @@ public class EasyscapePlugin extends Plugin
|
||||
{
|
||||
swap(client, "Teleport", option, target);
|
||||
}
|
||||
}
|
||||
|
||||
else if (config.getGamesNecklace() && target.contains("games necklace"))
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (!"easyscape".equals(event.getGroup()))
|
||||
{
|
||||
swap(client, config.getGamesNecklaceMode().toString(), option, target);
|
||||
return;
|
||||
}
|
||||
|
||||
else if (config.getDuelingRing() && target.contains("ring of dueling"))
|
||||
removeSwaps();
|
||||
addSwaps();
|
||||
}
|
||||
|
||||
private void addSwaps()
|
||||
{
|
||||
if (config.getBurningAmulet())
|
||||
{
|
||||
swap(client, config.getDuelingRingMode().toString(), option, target);
|
||||
menuManager.addSwap("remove", "burning amulet", config.getBurningAmuletMode().toString(), "burning amulet", true, false);
|
||||
}
|
||||
|
||||
else if (config.getGlory() && (target.contains("amulet of glory") || target.contains("amulet of eternal glory")))
|
||||
if (config.getCombatBracelet())
|
||||
{
|
||||
swap(client, config.getGloryMode().toString(), option, target);
|
||||
menuManager.addSwap("remove", "combat bracelet", config.getCombatBraceletMode().toString(), "combat bracelet", true, false);
|
||||
}
|
||||
|
||||
else if (config.getSkillsNecklace() && target.contains("skills necklace"))
|
||||
{
|
||||
swap(client, config.getSkillsNecklaceMode().toString(), option, target);
|
||||
}
|
||||
|
||||
else if (config.getNecklaceofPassage() && target.contains("necklace of passage"))
|
||||
{
|
||||
swap(client, config.getNecklaceofPassageMode().toString(), option, target);
|
||||
}
|
||||
if (config.getGamesNecklace())
|
||||
{
|
||||
menuManager.addSwap("remove", "games necklace", config.getGamesNecklaceMode().toString(), "games necklace", true, false);
|
||||
}
|
||||
|
||||
else if (config.getDigsitePendant() && target.contains("digsite pendant"))
|
||||
{
|
||||
swap(client, config.getDigsitePendantMode().toString(), option, target);
|
||||
}
|
||||
if (config.getDuelingRing())
|
||||
{
|
||||
menuManager.addSwap("remove", "ring of dueling", config.getDuelingRingMode().toString(), "ring of dueling", true, false);
|
||||
}
|
||||
|
||||
else if (config.getCombatBracelet() && target.contains("combat bracelet"))
|
||||
{
|
||||
swap(client, config.getCombatBraceletMode().toString(), option, target);
|
||||
}
|
||||
if (config.getGlory())
|
||||
{
|
||||
menuManager.addSwap("remove", "amulet of glory", config.getGloryMode().toString(), "amulet of glory", true, false);
|
||||
menuManager.addSwap("remove", "amulet of eternal glory", config.getGloryMode().toString(), "amulet of eternal glory", true, false);
|
||||
}
|
||||
|
||||
else if (config.getSlayerRing() && target.contains("slayer ring"))
|
||||
{
|
||||
swap(client, config.getSlayerRingMode().toString(), option, target);
|
||||
}
|
||||
if (config.getSkillsNecklace())
|
||||
{
|
||||
menuManager.addSwap("remove", "skills necklace", config.getSkillsNecklaceMode().toString(), "skills necklace", true, false);
|
||||
}
|
||||
|
||||
else if (config.getBurningAmulet() && target.contains("burning amulet"))
|
||||
{
|
||||
swap(client, config.getBurningAmuletMode().toString(), option, target);
|
||||
}
|
||||
if (config.getNecklaceofPassage())
|
||||
{
|
||||
menuManager.addSwap("remove", "necklace of passage", config.getNecklaceofPassageMode().toString(), "necklace of passage", true, false);
|
||||
}
|
||||
|
||||
else if (config.getXericsTalisman() && target.contains("xeric's talisman"))
|
||||
{
|
||||
swap(client, config.getXericsTalismanMode().toString(), option, target);
|
||||
}
|
||||
if (config.getDigsitePendant())
|
||||
{
|
||||
menuManager.addSwap("remove", "digsite pendant", config.getDigsitePendantMode().toString(), "digsite pendant", true, false);
|
||||
}
|
||||
|
||||
else if (config.getRingofWealth() && target.contains("ring of wealth"))
|
||||
{
|
||||
swap(client, config.getRingofWealthMode().toString(), option, target);
|
||||
}
|
||||
|
||||
if (config.getSlayerRing())
|
||||
{
|
||||
menuManager.addSwap("remove", "slayer ring", config.getSlayerRingMode().toString(), "slayer ring", true, false);
|
||||
}
|
||||
|
||||
else if (config.getXericsTalisman())
|
||||
{
|
||||
menuManager.addSwap("remove", "xeric's talisman", config.getXericsTalismanMode().toString(), "xeric's talisman", true, false);
|
||||
}
|
||||
|
||||
if (config.getRingofWealth())
|
||||
{
|
||||
menuManager.addSwap("remove", "ring of wealth", config.getRingofWealthMode().toString(), "ring of wealth", true, false);
|
||||
}
|
||||
|
||||
if (config.swapMax())
|
||||
{
|
||||
menuManager.addSwap("remove", "max cape", config.maxMode().toString(), "max cape", true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSwaps()
|
||||
{
|
||||
menuManager.removeSwaps("burning amulet");
|
||||
menuManager.removeSwaps("combat bracelet");
|
||||
menuManager.removeSwaps("games necklace");
|
||||
menuManager.removeSwaps("ring of dueling");
|
||||
menuManager.removeSwaps("amulet of glory");
|
||||
menuManager.removeSwaps("amulet of eternal glory");
|
||||
menuManager.removeSwaps("skills necklace");
|
||||
menuManager.removeSwaps("necklace of passage");
|
||||
menuManager.removeSwaps("digsite pendant");
|
||||
menuManager.removeSwaps("slayer ring");
|
||||
menuManager.removeSwaps("xeric's talisman");
|
||||
menuManager.removeSwaps("ring of wealth");
|
||||
}
|
||||
|
||||
private void delete(int target)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.runelite.client.plugins.easyscape.util;
|
||||
|
||||
public enum MaxCapeMode
|
||||
{
|
||||
WARRIORS_GUILD("Warriors' Guild"),
|
||||
FISHING_TELEPORT("Fishing Teleport"),
|
||||
CRAFTING_GUILD("Crafting Guild"),
|
||||
TELE_TO_POH("Tele to POH"),
|
||||
POH_PORTALS("POH Portals"),
|
||||
OTHER_TELEPORTS("Other Teleports"),
|
||||
SPELLBOOK("Spellbook"),
|
||||
FEATURES("Features");
|
||||
|
||||
private final String name;
|
||||
|
||||
MaxCapeMode(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ package net.runelite.client.plugins.easyscape.util;
|
||||
|
||||
public enum XericsTalismanMode
|
||||
{
|
||||
XERICS_LOOKOUT("Xeric's Lookout"),
|
||||
XERICS_LOOKOUT("Xeric's Look-out"),
|
||||
XERICS_GLADE("Xeric's Glade"),
|
||||
XERICS_INFERNO("Xeric's Inferno"),
|
||||
XERICS_HEART("Xeric's Heart"),
|
||||
|
||||
@@ -155,12 +155,16 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
{
|
||||
enableCustomization();
|
||||
}
|
||||
|
||||
loadCustomSwaps(config.customSwaps());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown()
|
||||
{
|
||||
disableCustomization();
|
||||
|
||||
loadCustomSwaps(""); // Removes all custom swaps
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -71,10 +71,7 @@ import net.runelite.client.util.Text;
|
||||
)
|
||||
public class RunecraftPlugin extends Plugin
|
||||
{
|
||||
private static final int[] CASTLE_WARS = {9776};
|
||||
private static final int[] FIRE_ALTAR = {10315};
|
||||
|
||||
|
||||
private static final int FIRE_ALTAR = 10315;
|
||||
private static final String POUCH_DECAYED_NOTIFICATION_MESSAGE = "Your rune pouch has decayed.";
|
||||
private static final String POUCH_DECAYED_MESSAGE = "Your pouch has decayed through use.";
|
||||
private static final List<Integer> DEGRADED_POUCHES = ImmutableList.of(
|
||||
@@ -82,12 +79,7 @@ public class RunecraftPlugin extends Plugin
|
||||
ItemID.LARGE_POUCH_5513,
|
||||
ItemID.GIANT_POUCH_5515
|
||||
);
|
||||
private static final List<Integer> POUCHES = ImmutableList.of(
|
||||
ItemID.SMALL_POUCH,
|
||||
ItemID.MEDIUM_POUCH,
|
||||
ItemID.LARGE_POUCH,
|
||||
ItemID.GIANT_POUCH
|
||||
);
|
||||
|
||||
private boolean wearingTiara;
|
||||
private boolean wearingCape;
|
||||
|
||||
@@ -133,6 +125,7 @@ public class RunecraftPlugin extends Plugin
|
||||
overlayManager.add(abyssOverlay);
|
||||
abyssOverlay.updateConfig();
|
||||
overlayManager.add(runecraftOverlay);
|
||||
addSwaps();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,6 +136,7 @@ public class RunecraftPlugin extends Plugin
|
||||
darkMage = null;
|
||||
degradedPouchInInventory = false;
|
||||
overlayManager.remove(runecraftOverlay);
|
||||
removeSwaps();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -155,14 +149,7 @@ public class RunecraftPlugin extends Plugin
|
||||
|
||||
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);
|
||||
}
|
||||
addSwaps();
|
||||
}
|
||||
|
||||
abyssOverlay.updateConfig();
|
||||
@@ -192,47 +179,34 @@ 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();
|
||||
|
||||
if (target.contains("ring of dueling") && option.contains("remove"))
|
||||
if (target.contains("ring of dueling") && option.contains("remove")) // Incompatible with easyscape
|
||||
{
|
||||
if (client.getLocalPlayer().getWorldLocation().getRegionID() != 10315)
|
||||
if (client.getLocalPlayer().getWorldLocation().getRegionID() != FIRE_ALTAR)
|
||||
{ //changes duel ring teleport options based on location
|
||||
swap(client, "duel arena", option, target);
|
||||
}
|
||||
else if (client.getLocalPlayer().getWorldLocation().getRegionID() == 10315)
|
||||
else if (client.getLocalPlayer().getWorldLocation().getRegionID() == FIRE_ALTAR)
|
||||
{
|
||||
swap(client, "castle wars", option, target);
|
||||
}
|
||||
}
|
||||
else if (target.contains("crafting cape") && option.contains("remove")) //teleport for crafting cape
|
||||
{
|
||||
swap(client, "Teleport", option, target);
|
||||
}
|
||||
else if (target.contains("max cape") && option.contains("remove")) //teleport for max cape
|
||||
{
|
||||
swap(client, "Crafting Guild", option, target);
|
||||
}
|
||||
else if (target.contains("altar") && option.contains("craft")) // Don't accidentally click the altar to craft
|
||||
{
|
||||
hide(option, target, true);
|
||||
hide(option, target);
|
||||
}
|
||||
else if (target.contains("pure") && option.contains("use")) // Don't accidentally use pure essence on altar
|
||||
{
|
||||
hide("use", target, true);
|
||||
hide("drop", target, true);
|
||||
}
|
||||
else if (option.equals("fill") && id != 9)
|
||||
{
|
||||
swap(client, "empty", option, target);
|
||||
hide("use", target);
|
||||
hide("drop", target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void hide(String option, String target, boolean contains)
|
||||
private void hide(String option, String target)
|
||||
{
|
||||
final MenuEntry[] entries = client.getMenuEntries();
|
||||
int index = searchIndex(entries, option, target, contains);
|
||||
int index = searchIndex(entries, option, target);
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
@@ -255,7 +229,7 @@ public class RunecraftPlugin extends Plugin
|
||||
client.setMenuEntries(newEntries);
|
||||
}
|
||||
|
||||
private int searchIndex(MenuEntry[] entries, String option, String target, boolean contains)
|
||||
private int searchIndex(MenuEntry[] entries, String option, String target)
|
||||
{
|
||||
for (int i = entries.length - 1; i >= 0; i--)
|
||||
{
|
||||
@@ -264,7 +238,7 @@ public class RunecraftPlugin extends Plugin
|
||||
String entryTarget = Text.removeTags(entry.getTarget()).toLowerCase();
|
||||
|
||||
if (entryOption.contains(option.toLowerCase())
|
||||
&& (entryTarget.equals(target) || (entryTarget.contains(target) && contains)))
|
||||
&& (entryTarget.contains(target)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@@ -346,4 +320,24 @@ public class RunecraftPlugin extends Plugin
|
||||
darkMage = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void addSwaps()
|
||||
{
|
||||
if (config.essPouch())
|
||||
{
|
||||
menuManager.addSwap("deposit", "pouch", 2, 57, "fill", "pouch", 9, 1007);
|
||||
menuManager.addSwap("fill", "pouch", "empty", "pouch", true, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
menuManager.removeSwap("deposit", "pouch", 2, 57, "fill", "pouch", 9, 1007);
|
||||
menuManager.removeSwap("fill", "pouch", "empty", "pouch", true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSwaps()
|
||||
{
|
||||
menuManager.removeSwap("deposit", "pouch", 2, 57, "fill", "pouch", 9, 1007);
|
||||
menuManager.removeSwap("fill", "pouch", "empty", "pouch", true, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user