Add priority menu entries to menumanager and update some plugins to use it (#284)
* Add priority menu entries to menumanager and update some plugins to use it * Don't check target for walk-here * Make mark-tile lower priority than walk here when shift is pressed * comment out shiftwalker unused code * More menu entry stuff * Check The Feud completion state to see if someone is able to blackjack * Revert changes to BATools (doesn't work) * Merge (and improve) Easyscape
This commit is contained in:
@@ -559,7 +559,7 @@ public enum Varbits
|
||||
QUEST_THE_EYES_OF_GLOUPHRIE(2497),
|
||||
QUEST_FAIRYTALE_I_GROWING_PAINS(1803),
|
||||
QUEST_FAIRYTALE_II_CURE_A_QUEEN(2326),
|
||||
QUEST_THE_FEUD(334),
|
||||
QUEST_THE_FEUD(334), // 14 = able to pickpocket
|
||||
QUEST_FORGETTABLE_TALE(822),
|
||||
QUEST_GARDEN_OF_TRANQUILLITY(961),
|
||||
QUEST_GHOSTS_AHOY(217),
|
||||
@@ -628,7 +628,12 @@ public enum Varbits
|
||||
/**
|
||||
* Spellbook filtering (1 = unfiltered, 0 = filtered)
|
||||
*/
|
||||
FILTER_SPELLBOOK(6718);
|
||||
FILTER_SPELLBOOK(6718),
|
||||
|
||||
/**
|
||||
* POH Building mode (1 = yes, 0 = no)
|
||||
*/
|
||||
BUILDING_MODE(2176);
|
||||
|
||||
/**
|
||||
* The raw varbit ID.
|
||||
|
||||
@@ -31,8 +31,10 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -60,6 +62,7 @@ public class MenuManager
|
||||
*/
|
||||
private static final int IDX_LOWER = 4;
|
||||
private static final int IDX_UPPER = 8;
|
||||
private static final Pattern LEVEL_PATTERN = Pattern.compile("\\(level-[0-9]*\\)");
|
||||
|
||||
private final Client client;
|
||||
private final EventBus eventBus;
|
||||
@@ -69,6 +72,7 @@ public class MenuManager
|
||||
//Used to manage custom non-player menu options
|
||||
private final Multimap<Integer, WidgetMenuOption> managedMenuOptions = HashMultimap.create();
|
||||
private final Set<String> npcMenuOptions = new HashSet<>();
|
||||
private final Map<String, Set<String>> priorityEntries = new HashMap<>();
|
||||
|
||||
@Inject
|
||||
private MenuManager(Client client, EventBus eventBus)
|
||||
@@ -119,12 +123,12 @@ public class MenuManager
|
||||
{
|
||||
int widgetId = event.getActionParam1();
|
||||
Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId);
|
||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||
|
||||
for (WidgetMenuOption currentMenu : options)
|
||||
{
|
||||
if (!menuContainsCustomMenu(currentMenu))//Don't add if we have already added it to this widget
|
||||
{
|
||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
|
||||
|
||||
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
||||
@@ -136,6 +140,49 @@ public class MenuManager
|
||||
client.setMenuEntries(menuEntries);
|
||||
}
|
||||
}
|
||||
|
||||
List<MenuEntry> menuEntryList = Arrays.asList(menuEntries);
|
||||
boolean shouldPurge = menuEntryList.stream().anyMatch(m ->
|
||||
{
|
||||
String opt = Text.standardize(m.getOption());
|
||||
String tgt = Text.standardize(m.getTarget());
|
||||
tgt = LEVEL_PATTERN.matcher(tgt).replaceAll("").trim();
|
||||
|
||||
if (!priorityEntries.containsKey(opt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return priorityEntries.get(opt).contains(tgt);
|
||||
});
|
||||
|
||||
if (shouldPurge)
|
||||
{
|
||||
client.setMenuEntries(menuEntryList.stream().filter(m ->
|
||||
{
|
||||
String opt = Text.standardize(m.getOption());
|
||||
String tgt = Text.standardize(m.getTarget());
|
||||
tgt = LEVEL_PATTERN.matcher(tgt).replaceAll("").trim();
|
||||
|
||||
if (opt.equals("cancel"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!priorityEntries.containsKey(opt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Gets overridden by actor names
|
||||
if (opt.equals("walk here"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return priorityEntries.get(opt).contains(tgt);
|
||||
}).toArray(MenuEntry[]::new));
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayerMenuItem(String menuText)
|
||||
@@ -307,4 +354,38 @@ public class MenuManager
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the map of menu entries which when present, will remove all entries except for this one
|
||||
*/
|
||||
public void addPriorityEntry(String option, String target)
|
||||
{
|
||||
option = Text.standardize(option);
|
||||
target = Text.standardize(target);
|
||||
|
||||
Set<String> targets = priorityEntries.getOrDefault(option, new HashSet<>());
|
||||
|
||||
targets.add(target);
|
||||
|
||||
priorityEntries.put(option, targets);
|
||||
}
|
||||
|
||||
public void removePriorityEntry(String option, String target)
|
||||
{
|
||||
option = Text.standardize(option);
|
||||
target = Text.standardize(target);
|
||||
|
||||
Set<String> targets = priorityEntries.getOrDefault(option, new HashSet<>());
|
||||
|
||||
targets.remove(target);
|
||||
|
||||
if (targets.isEmpty())
|
||||
{
|
||||
priorityEntries.remove(option);
|
||||
}
|
||||
else
|
||||
{
|
||||
priorityEntries.put(option, targets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,20 +27,20 @@ package net.runelite.client.plugins.blackjack;
|
||||
import com.google.inject.Binder;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.Quest;
|
||||
import net.runelite.api.QuestState;
|
||||
import static net.runelite.api.Varbits.QUEST_THE_FEUD;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
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;
|
||||
import static net.runelite.client.util.MenuUtil.swap;
|
||||
|
||||
/**
|
||||
* Authors gazivodag longstreet
|
||||
@@ -55,15 +55,21 @@ import net.runelite.client.plugins.PluginType;
|
||||
@Slf4j
|
||||
public class BlackjackPlugin extends Plugin
|
||||
{
|
||||
private static final String PICKPOCKET = "Pickpocket";
|
||||
private static final String KNOCK_OUT = "Knock-out";
|
||||
private static final String LURE = "Lure";
|
||||
private static final String BANDIT = "Bandit";
|
||||
private static final String MENAPHITE = "Menaphite Thug";
|
||||
|
||||
@Inject
|
||||
Client client;
|
||||
private Client client;
|
||||
|
||||
private long timeSinceKnockout;
|
||||
private long timeSinceAggro;
|
||||
@Inject
|
||||
private MenuManager menuManager;
|
||||
|
||||
@Getter
|
||||
private long currentGameTick;
|
||||
private int lastKnockout;
|
||||
private boolean pickpocketing;
|
||||
private boolean ableToBlackJack;
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder)
|
||||
@@ -73,80 +79,87 @@ public class BlackjackPlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
currentGameTick = 0;
|
||||
menuManager.addPriorityEntry(LURE, BANDIT);
|
||||
menuManager.addPriorityEntry(LURE, MENAPHITE);
|
||||
|
||||
menuManager.addPriorityEntry(KNOCK_OUT, BANDIT);
|
||||
menuManager.addPriorityEntry(KNOCK_OUT, MENAPHITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
currentGameTick = 0;
|
||||
menuManager.removePriorityEntry(LURE, BANDIT);
|
||||
menuManager.removePriorityEntry(LURE, MENAPHITE);
|
||||
|
||||
menuManager.removePriorityEntry(PICKPOCKET, BANDIT);
|
||||
menuManager.removePriorityEntry(PICKPOCKET, MENAPHITE);
|
||||
|
||||
menuManager.removePriorityEntry(KNOCK_OUT, BANDIT);
|
||||
menuManager.removePriorityEntry(KNOCK_OUT, MENAPHITE);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick gameTick)
|
||||
{
|
||||
currentGameTick++;
|
||||
if (ableToBlackJack && pickpocketing && client.getTickCount() >= lastKnockout + 4)
|
||||
{
|
||||
pickpocketing = false;
|
||||
|
||||
menuManager.removePriorityEntry(PICKPOCKET, BANDIT);
|
||||
menuManager.removePriorityEntry(PICKPOCKET, MENAPHITE);
|
||||
|
||||
menuManager.addPriorityEntry(KNOCK_OUT, BANDIT);
|
||||
menuManager.addPriorityEntry(KNOCK_OUT, MENAPHITE);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMenuEntryAdded(MenuEntryAdded event)
|
||||
{
|
||||
// Lure has higher priority than knock-out
|
||||
if (event.getTarget().contains(MENAPHITE) || event.getTarget().contains(BANDIT)
|
||||
&& event.getOption().equals(LURE))
|
||||
{
|
||||
swap(client, KNOCK_OUT, LURE, event.getTarget(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChatMessage(ChatMessage chatMessage)
|
||||
{
|
||||
if (chatMessage.getType() == ChatMessageType.SPAM)
|
||||
{
|
||||
if (chatMessage.getMessage().equals("You smack the bandit over the head and render them unconscious."))
|
||||
if (chatMessage.getMessage().equals("You smack the bandit over the head and render them unconscious.")
|
||||
|| chatMessage.getMessage().equals("Your blow only glances off the bandit's head."))
|
||||
{
|
||||
timeSinceKnockout = getCurrentGameTick();
|
||||
}
|
||||
if (chatMessage.getMessage().equals("Your blow only glances off the bandit's head."))
|
||||
{
|
||||
timeSinceAggro = getCurrentGameTick();
|
||||
menuManager.removePriorityEntry(KNOCK_OUT, BANDIT);
|
||||
menuManager.removePriorityEntry(KNOCK_OUT, MENAPHITE);
|
||||
|
||||
menuManager.addPriorityEntry(PICKPOCKET, BANDIT);
|
||||
menuManager.addPriorityEntry(PICKPOCKET, MENAPHITE);
|
||||
|
||||
lastKnockout = client.getTickCount();
|
||||
pickpocketing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
|
||||
public void onVarbitChanged(VarbitChanged event)
|
||||
{
|
||||
String target = menuEntryAdded.getTarget().toLowerCase();
|
||||
if ((target.contains("bandit") || target.contains("menaphite thug")))
|
||||
{
|
||||
Quest quest = Quest.THE_FEUD;
|
||||
if (quest.getState(client) == QuestState.FINISHED)
|
||||
{
|
||||
if (currentGameTick < (timeSinceKnockout + 4))
|
||||
{
|
||||
stripSpecificEntries("pickpocket");
|
||||
}
|
||||
if (currentGameTick < (timeSinceAggro + 4))
|
||||
{
|
||||
stripSpecificEntries("pickpocket");
|
||||
}
|
||||
stripSpecificEntries("knock-out");
|
||||
}
|
||||
}
|
||||
}
|
||||
ableToBlackJack = client.getVar(QUEST_THE_FEUD) >= 13;
|
||||
|
||||
private void stripSpecificEntries(String exceptFor)
|
||||
{
|
||||
MenuEntry[] currentEntires = client.getMenuEntries();
|
||||
MenuEntry[] newEntries = new MenuEntry[2];
|
||||
|
||||
for (MenuEntry currentEntry : currentEntires)
|
||||
if (!ableToBlackJack)
|
||||
{
|
||||
if (currentEntry.getOption().toLowerCase().equals(exceptFor.toLowerCase()))
|
||||
{
|
||||
newEntries[1] = currentEntry;
|
||||
}
|
||||
if (currentEntry.getOption().toLowerCase().equals("lure"))
|
||||
{
|
||||
newEntries[0] = currentEntry;
|
||||
}
|
||||
}
|
||||
menuManager.removePriorityEntry(LURE, BANDIT);
|
||||
menuManager.removePriorityEntry(LURE, MENAPHITE);
|
||||
|
||||
if (newEntries[0] != null && newEntries[1] != null)
|
||||
{
|
||||
client.setMenuEntries(newEntries);
|
||||
menuManager.removePriorityEntry(KNOCK_OUT, BANDIT);
|
||||
menuManager.removePriorityEntry(KNOCK_OUT, MENAPHITE);
|
||||
|
||||
menuManager.removePriorityEntry(PICKPOCKET, BANDIT);
|
||||
menuManager.removePriorityEntry(PICKPOCKET, MENAPHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.plugins.easyscape.util.DuelingRingMode;
|
||||
import net.runelite.client.plugins.easyscape.util.EssenceMode;
|
||||
import net.runelite.client.plugins.easyscape.util.GamesNecklaceMode;
|
||||
import net.runelite.client.plugins.easyscape.util.GloryMode;
|
||||
|
||||
@@ -488,30 +487,6 @@ public interface EasyscapeConfig extends Config
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "swapEssencePounch",
|
||||
name = "Swap Essence Pouch",
|
||||
description = "",
|
||||
position = 38,
|
||||
group = "Miscellaneous swapper"
|
||||
)
|
||||
default boolean getSwapEssencePouch()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "essenceMode",
|
||||
name = "Mode",
|
||||
description = "",
|
||||
position = 39,
|
||||
group = "Miscellaneous swapper"
|
||||
)
|
||||
default EssenceMode getEssenceMode()
|
||||
{
|
||||
return EssenceMode.RUNECRAFTING;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "swapGamesNecklace",
|
||||
name = "Swap Games Necklace",
|
||||
|
||||
@@ -25,23 +25,19 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.easyscape;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.MenuAction;
|
||||
import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET;
|
||||
import static net.runelite.api.MenuAction.WALK;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import static net.runelite.api.ObjectID.PORTAL_4525;
|
||||
import net.runelite.api.Player;
|
||||
import static net.runelite.api.Varbits.BUILDING_MODE;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.GameObjectDespawned;
|
||||
import net.runelite.api.events.GameObjectSpawned;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -61,7 +57,6 @@ public class EasyscapePlugin extends Plugin
|
||||
private static final int PURO_PURO_REGION_ID = 10307;
|
||||
|
||||
private MenuEntry[] entries;
|
||||
private boolean inHouse = false;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@@ -75,6 +70,16 @@ public class EasyscapePlugin extends Plugin
|
||||
return configManager.getConfig(EasyscapeConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startUp()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown()
|
||||
{
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMenuEntryAdded(MenuEntryAdded event)
|
||||
{
|
||||
@@ -83,27 +88,18 @@ public class EasyscapePlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
Widget loginScreenOne = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN);
|
||||
Widget loginScreenTwo = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY);
|
||||
|
||||
if (loginScreenOne != null || loginScreenTwo != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String option = Text.removeTags(event.getOption()).toLowerCase();
|
||||
final String target = Text.removeTags(event.getTarget()).toLowerCase();
|
||||
final String option = Text.standardize(event.getOption());
|
||||
final String target = Text.standardize(event.getTarget());
|
||||
|
||||
entries = client.getMenuEntries();
|
||||
|
||||
Widget widgetBankTitleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
|
||||
|
||||
if (option.contains("withdraw") || option.contains("deposit"))
|
||||
{
|
||||
if (config.getWithdrawOne())
|
||||
{
|
||||
for (String item : config.getWithdrawOneItems().split(","))
|
||||
for (String item : Text.fromCSV(config.getWithdrawOneItems()))
|
||||
{
|
||||
item = item.trim();
|
||||
if (target.equalsIgnoreCase(item))
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Withdraw-1", option, target);
|
||||
swap(client, "Deposit-1", option, target);
|
||||
@@ -113,10 +109,9 @@ public class EasyscapePlugin extends Plugin
|
||||
|
||||
if (config.getWithdrawFive())
|
||||
{
|
||||
for (String item : config.getWithdrawFiveItems().split(","))
|
||||
for (String item : Text.fromCSV(config.getWithdrawFiveItems()))
|
||||
{
|
||||
item = item.trim();
|
||||
if (target.equalsIgnoreCase(item))
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Withdraw-5", option, target);
|
||||
swap(client, "Deposit-5", option, target);
|
||||
@@ -126,10 +121,9 @@ public class EasyscapePlugin extends Plugin
|
||||
|
||||
if (config.getWithdrawTen())
|
||||
{
|
||||
for (String item : config.getWithdrawTenItems().split(","))
|
||||
for (String item : Text.fromCSV(config.getWithdrawTenItems()))
|
||||
{
|
||||
item = item.trim();
|
||||
if (target.equalsIgnoreCase(item))
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Withdraw-10", option, target);
|
||||
swap(client, "Deposit-10", option, target);
|
||||
@@ -139,10 +133,9 @@ public class EasyscapePlugin extends Plugin
|
||||
|
||||
if (config.getWithdrawX())
|
||||
{
|
||||
for (String item : config.getWithdrawXItems().split(","))
|
||||
for (String item : Text.fromCSV(config.getWithdrawXItems()))
|
||||
{
|
||||
item = item.trim();
|
||||
if (target.equalsIgnoreCase(item))
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Withdraw-" + config.getWithdrawXAmount(), option, target);
|
||||
swap(client, "Deposit-" + config.getWithdrawXAmount(), option, target);
|
||||
@@ -152,111 +145,116 @@ public class EasyscapePlugin extends Plugin
|
||||
|
||||
if (config.getWithdrawAll())
|
||||
{
|
||||
for (String item : config.getWithdrawAllItems().split(","))
|
||||
for (String item : Text.fromCSV(config.getWithdrawAllItems()))
|
||||
{
|
||||
item = item.trim();
|
||||
if (target.equalsIgnoreCase(item))
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Withdraw-All", option, target);
|
||||
swap(client, "Deposit-All", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapBuyOne() && !config.getBuyOneItems().equals(""))
|
||||
if (option.contains("buy"))
|
||||
{
|
||||
for (String item : config.getBuyOneItems().split(","))
|
||||
if (config.getSwapBuyOne() && !config.getBuyOneItems().equals(""))
|
||||
{
|
||||
if (target.equalsIgnoreCase(item.trim()))
|
||||
for (String item : Text.fromCSV(config.getBuyOneItems()))
|
||||
{
|
||||
swap(client, "Buy 1", option, target);
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Buy 1", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapBuyFive() && !config.getBuyFiveItems().equals(""))
|
||||
{
|
||||
for (String item : Text.fromCSV(config.getBuyFiveItems()))
|
||||
{
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Buy 5", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapBuyTen() && !config.getBuyTenItems().equals(""))
|
||||
{
|
||||
for (String item : Text.fromCSV(config.getBuyTenItems()))
|
||||
{
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Buy 10", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapBuyFifty() && !config.getBuyFiftyItems().equals(""))
|
||||
{
|
||||
for (String item : Text.fromCSV(config.getBuyFiftyItems()))
|
||||
{
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Buy 50", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapBuyFive() && !config.getBuyFiveItems().equals(""))
|
||||
else if (option.contains("sell"))
|
||||
{
|
||||
for (String item : config.getBuyFiveItems().split(","))
|
||||
if (config.getSwapSellOne() && !config.getSellOneItems().equals(""))
|
||||
{
|
||||
if (target.equalsIgnoreCase(item.trim()))
|
||||
for (String item : Text.fromCSV(config.getSellOneItems()))
|
||||
{
|
||||
swap(client, "Buy 5", option, target);
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Sell 1", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapBuyTen() && !config.getBuyTenItems().equals(""))
|
||||
{
|
||||
for (String item : config.getBuyTenItems().split(","))
|
||||
if (config.getSwapSellFive() && !Strings.isNullOrEmpty(config.getSellFiveItems()))
|
||||
{
|
||||
if (target.equalsIgnoreCase(item.trim()))
|
||||
for (String item : Text.fromCSV(config.getSellFiveItems()))
|
||||
{
|
||||
swap(client, "Buy 10", option, target);
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Sell 5", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapBuyFifty() && !config.getBuyFiftyItems().equals(""))
|
||||
{
|
||||
for (String item : config.getBuyFiftyItems().split(","))
|
||||
if (config.getSwapSellTen() && !Strings.isNullOrEmpty(config.getSellTenItems()))
|
||||
{
|
||||
if (target.equalsIgnoreCase(item.trim()))
|
||||
for (String item : Text.fromCSV(config.getSellTenItems()))
|
||||
{
|
||||
swap(client, "Buy 50", option, target);
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Sell 10", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapSellOne() && !config.getSellOneItems().equals(""))
|
||||
{
|
||||
for (String item : config.getSellOneItems().split(","))
|
||||
if (config.getSwapSellFifty() && !Strings.isNullOrEmpty(config.getSellFiftyItems()))
|
||||
{
|
||||
if (target.equalsIgnoreCase(item.trim()))
|
||||
for (String item : Text.fromCSV(config.getSellFiftyItems()))
|
||||
{
|
||||
swap(client, "Sell 1", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapSellFive() && !config.getSellFiveItems().equals(""))
|
||||
{
|
||||
for (String item : config.getSellFiveItems().split(","))
|
||||
{
|
||||
if (target.equalsIgnoreCase(item.trim()))
|
||||
{
|
||||
swap(client, "Sell 5", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapSellTen() && !config.getSellTenItems().equals(""))
|
||||
{
|
||||
for (String item : config.getSellTenItems().split(","))
|
||||
{
|
||||
if (target.equalsIgnoreCase(item.trim()))
|
||||
{
|
||||
swap(client, "Sell 10", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapSellFifty() && !config.getSellFiftyItems().equals(""))
|
||||
{
|
||||
for (String item : config.getSellFiftyItems().split(","))
|
||||
{
|
||||
if (target.equalsIgnoreCase(item.trim()))
|
||||
{
|
||||
swap(client, "Sell 50", option, target);
|
||||
if (target.equals(Text.standardize(item)))
|
||||
{
|
||||
swap(client, "Sell 50", option, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getRemoveObjects() && !config.getRemovedObjects().equals(""))
|
||||
{
|
||||
for (String removed : config.getRemovedObjects().split(","))
|
||||
for (String removed : Text.fromCSV(config.getRemovedObjects()))
|
||||
{
|
||||
removed = removed.trim();
|
||||
if (target.contains("(") && target.split(" \\(")[0].equalsIgnoreCase(removed))
|
||||
removed = Text.standardize(removed);
|
||||
if (target.contains("(") && target.split(" \\(")[0].equals(removed))
|
||||
{
|
||||
delete(event.getIdentifier());
|
||||
}
|
||||
@@ -294,7 +292,7 @@ public class EasyscapePlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getEasyConstruction() && !config.getConstructionItems().equals("") && inHouse)
|
||||
if (config.getEasyConstruction() && client.getVar(BUILDING_MODE) == 1 && !Strings.isNullOrEmpty(config.getConstructionItems()))
|
||||
{
|
||||
if (event.getType() == WALK.getId())
|
||||
{
|
||||
@@ -306,9 +304,9 @@ public class EasyscapePlugin extends Plugin
|
||||
|
||||
for (int i = entries.length - 1; i >= 0; i--)
|
||||
{
|
||||
for (String item : config.getConstructionItems().split(","))
|
||||
for (String item : Text.fromCSV(config.getConstructionItems()))
|
||||
{
|
||||
if (item.trim().equalsIgnoreCase(Text.removeTags(entries[i].getTarget())))
|
||||
if (item.equalsIgnoreCase(Text.removeTags(entries[i].getTarget())))
|
||||
{
|
||||
if (!entries[i].getOption().equalsIgnoreCase("remove"))
|
||||
{
|
||||
@@ -322,7 +320,7 @@ public class EasyscapePlugin extends Plugin
|
||||
client.setMenuEntries(entries);
|
||||
}
|
||||
|
||||
if (config.getSwapSmithing())
|
||||
if (config.getSwapSmithing() && option.contains("smith"))
|
||||
{
|
||||
if (option.equalsIgnoreCase("Smith 1"))
|
||||
{
|
||||
@@ -334,86 +332,46 @@ public class EasyscapePlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getSwapTanning() && option.equalsIgnoreCase("Tan 1"))
|
||||
else if (config.getSwapTanning() && option.equalsIgnoreCase("Tan 1"))
|
||||
{
|
||||
swap(client, "Tan All", option, target);
|
||||
}
|
||||
|
||||
if (config.getSwapSawmill() && target.equalsIgnoreCase("Sawmill operator"))
|
||||
else if (config.getSwapSawmill() && target.equalsIgnoreCase("Sawmill operator"))
|
||||
{
|
||||
swap(client, "Buy-plank", option, target);
|
||||
}
|
||||
|
||||
if (config.getSwapSawmillPlanks() && option.equalsIgnoreCase("Buy 1"))
|
||||
else if (config.getSwapSawmillPlanks() && option.equalsIgnoreCase("Buy 1"))
|
||||
{
|
||||
swap(client, "Buy All", option, target);
|
||||
}
|
||||
|
||||
if (option.equalsIgnoreCase("Clear-All") && target.equalsIgnoreCase("bank Filler"))
|
||||
else if (option.equalsIgnoreCase("Clear-All") && target.equalsIgnoreCase("Bank Filler"))
|
||||
{
|
||||
swap(client, "Clear", option, target);
|
||||
}
|
||||
|
||||
if (target.toLowerCase().contains("ardougne cloak") && config.getSwapArdougneCape())
|
||||
else if (target.contains("ardougne cloak") && config.getSwapArdougneCape())
|
||||
{
|
||||
swap(client, "Kandarin Monastery", option, target);
|
||||
swap(client, "Monastery Teleport", option, target);
|
||||
}
|
||||
|
||||
if (config.getSwapEssencePouch())
|
||||
else if (config.getGamesNecklace() && target.toLowerCase().contains("games necklace"))
|
||||
{
|
||||
if (isEssencePouch(target))
|
||||
{
|
||||
switch (config.getEssenceMode())
|
||||
{
|
||||
case RUNECRAFTING:
|
||||
if (widgetBankTitleBar == null || widgetBankTitleBar.isHidden())
|
||||
{
|
||||
swap(client, "Empty", option, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
swap(client, "Fill", option, target);
|
||||
}
|
||||
break;
|
||||
case ESSENCE_MINING:
|
||||
if (widgetBankTitleBar == null || widgetBankTitleBar.isHidden())
|
||||
{
|
||||
swap(client, "Fill", option, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
swap(client, "Empty", option, target);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
swap(client, config.getGamesNecklaceMode().toString(), option, target);
|
||||
}
|
||||
|
||||
if (config.getGamesNecklace())
|
||||
else if (config.getDuelingRing() && target.contains("ring of dueling"))
|
||||
{
|
||||
if (target.toLowerCase().contains("games necklace"))
|
||||
{
|
||||
swap(client, config.getGamesNecklaceMode().toString(), option, target);
|
||||
}
|
||||
swap(client, config.getDuelingRingMode().toString(), option, target);
|
||||
}
|
||||
|
||||
if (config.getDuelingRing())
|
||||
{
|
||||
if (target.toLowerCase().contains("ring of dueling"))
|
||||
{
|
||||
swap(client, config.getDuelingRingMode().toString(), option, target);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getGlory())
|
||||
else if (config.getGlory() && (target.contains("amulet of glory") || target.contains("amulet of eternal glory")))
|
||||
{
|
||||
if (target.toLowerCase().contains("amulet of glory") || target.toLowerCase().contains("amulet of eternal glory"))
|
||||
{
|
||||
swap(client, config.getGloryMode().toString(), option, target);
|
||||
}
|
||||
swap(client, config.getGloryMode().toString(), option, target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,34 +388,6 @@ public class EasyscapePlugin extends Plugin
|
||||
client.setMenuEntries(entries);
|
||||
}
|
||||
|
||||
private boolean isEssencePouch(String target)
|
||||
{
|
||||
return (target.equalsIgnoreCase("Small Pouch") ||
|
||||
target.equalsIgnoreCase("Medium Pouch") ||
|
||||
target.equalsIgnoreCase("Large Pouch") ||
|
||||
target.equalsIgnoreCase("Giant Pouch"));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameObjectSpawned(GameObjectSpawned event)
|
||||
{
|
||||
final GameObject gameObject = event.getGameObject();
|
||||
if (PORTAL_4525 == gameObject.getId())
|
||||
{
|
||||
this.inHouse = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameObjectDespawned(GameObjectDespawned event)
|
||||
{
|
||||
final GameObject gameObject = event.getGameObject();
|
||||
if (PORTAL_4525 == gameObject.getId())
|
||||
{
|
||||
this.inHouse = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPuroPuro()
|
||||
{
|
||||
Player player = client.getLocalPlayer();
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Alan Baumgartner <https://github.com/alanbaumgartner>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.easyscape.util;
|
||||
|
||||
public enum EssenceMode
|
||||
{
|
||||
RUNECRAFTING("Runecrafting"),
|
||||
ESSENCE_MINING("Essence Mining");
|
||||
|
||||
private final String name;
|
||||
|
||||
EssenceMode(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -210,16 +210,17 @@ public class GroundMarkerPlugin extends Plugin
|
||||
{
|
||||
if (hotKeyPressed && event.getOption().equals(WALK_HERE))
|
||||
{
|
||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
|
||||
// Can't insert into abstract list you get from Arrays.asList()
|
||||
List<MenuEntry> menuEntries = new ArrayList<>(Arrays.asList(client.getMenuEntries()));
|
||||
|
||||
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
||||
MenuEntry menuEntry = new MenuEntry();
|
||||
|
||||
menuEntry.setOption(MARK);
|
||||
menuEntry.setTarget(event.getTarget());
|
||||
menuEntry.setType(MenuAction.CANCEL.getId());
|
||||
|
||||
client.setMenuEntries(menuEntries);
|
||||
menuEntries.add(menuEntries.size() - 1, menuEntry);
|
||||
client.setMenuEntries(menuEntries.toArray(new MenuEntry[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -624,33 +624,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private int searchIndex(MenuEntry[] entries, String option, String target, boolean strict)
|
||||
{
|
||||
for (int i = entries.length - 1; i >= 0; i--)
|
||||
{
|
||||
MenuEntry entry = entries[i];
|
||||
String entryOption = Text.removeTags(entry.getOption()).toLowerCase();
|
||||
String entryTarget = Text.removeTags(entry.getTarget()).toLowerCase();
|
||||
|
||||
if (strict)
|
||||
{
|
||||
if (entryOption.equals(option) && entryTarget.equals(target))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entryOption.contains(option.toLowerCase()) && entryTarget.equals(target))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void removeShiftClickCustomizationMenus()
|
||||
{
|
||||
menuManager.removeManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE);
|
||||
|
||||
@@ -26,11 +26,12 @@ package net.runelite.client.plugins.shiftwalker;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
// import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("shiftwalkhere")
|
||||
public interface ShiftWalkerConfig extends Config
|
||||
{
|
||||
/*
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "shiftWalkEverything",
|
||||
@@ -62,5 +63,6 @@ public interface ShiftWalkerConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
package net.runelite.client.plugins.shiftwalker;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public final class ShiftWalkerGroups
|
||||
{
|
||||
//Specific Targets to limit the walking to
|
||||
private static final String BOX_TRAP = "BOX TRAP";
|
||||
private static final String BOX_TRAP_SHAKING = "SHAKING BOX";
|
||||
|
||||
//Specific menu options to replace
|
||||
private static final String BOX_TRAP_DISMANTLE = "DISMANTLE";
|
||||
private static final String BOX_TRAP_CHECK = "CHECK";
|
||||
|
||||
private static final String ATTACK_OPTIONS_ATTACK = "ATTACK";
|
||||
|
||||
public static final HashSet<String> BOX_TRAP_TARGETS = new HashSet<>();
|
||||
public static final HashSet<String> BOX_TRAP_KEYWORDS = new HashSet<>();
|
||||
public static final HashSet<String> ATTACK_OPTIONS_KEYWORDS = new HashSet<>();
|
||||
|
||||
static
|
||||
{
|
||||
BOX_TRAP_TARGETS.add(BOX_TRAP);
|
||||
BOX_TRAP_TARGETS.add(BOX_TRAP_SHAKING);
|
||||
|
||||
BOX_TRAP_KEYWORDS.add(BOX_TRAP_DISMANTLE);
|
||||
BOX_TRAP_KEYWORDS.add(BOX_TRAP_CHECK);
|
||||
|
||||
ATTACK_OPTIONS_KEYWORDS.add(ATTACK_OPTIONS_ATTACK);
|
||||
}
|
||||
|
||||
}
|
||||
package net.runelite.client.plugins.shiftwalker;
|
||||
|
||||
// import java.util.HashSet;
|
||||
|
||||
public final class ShiftWalkerGroups
|
||||
{
|
||||
/*//Specific Targets to limit the walking to
|
||||
private static final String BOX_TRAP = "BOX TRAP";
|
||||
private static final String BOX_TRAP_SHAKING = "SHAKING BOX";
|
||||
|
||||
//Specific menu options to replace
|
||||
private static final String BOX_TRAP_DISMANTLE = "DISMANTLE";
|
||||
private static final String BOX_TRAP_CHECK = "CHECK";
|
||||
|
||||
private static final String ATTACK_OPTIONS_ATTACK = "ATTACK";
|
||||
|
||||
public static final HashSet<String> BOX_TRAP_TARGETS = new HashSet<>();
|
||||
public static final HashSet<String> BOX_TRAP_KEYWORDS = new HashSet<>();
|
||||
public static final HashSet<String> ATTACK_OPTIONS_KEYWORDS = new HashSet<>();
|
||||
|
||||
static
|
||||
{
|
||||
BOX_TRAP_TARGETS.add(BOX_TRAP);
|
||||
BOX_TRAP_TARGETS.add(BOX_TRAP_SHAKING);
|
||||
|
||||
BOX_TRAP_KEYWORDS.add(BOX_TRAP_DISMANTLE);
|
||||
BOX_TRAP_KEYWORDS.add(BOX_TRAP_CHECK);
|
||||
|
||||
ATTACK_OPTIONS_KEYWORDS.add(ATTACK_OPTIONS_ATTACK);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ShiftWalkerInputListener implements KeyListener
|
||||
{
|
||||
if (event.getKeyCode() == KeyEvent.VK_SHIFT)
|
||||
{
|
||||
plugin.setHotKeyPressed(true);
|
||||
plugin.startPrioritizing();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ShiftWalkerInputListener implements KeyListener
|
||||
{
|
||||
if (event.getKeyCode() == KeyEvent.VK_SHIFT)
|
||||
{
|
||||
plugin.setHotKeyPressed(false);
|
||||
plugin.stopPrioritizing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,19 +26,14 @@ package net.runelite.client.plugins.shiftwalker;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.events.FocusChanged;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.input.KeyManager;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
/**
|
||||
* Shift Walker Plugin. Credit to MenuEntrySwapperPlugin for code some code structure used here.
|
||||
@@ -54,10 +49,6 @@ public class ShiftWalkerPlugin extends Plugin
|
||||
{
|
||||
|
||||
private static final String WALK_HERE = "WALK HERE";
|
||||
private static final String CANCEL = "CANCEL";
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ShiftWalkerConfig config;
|
||||
@@ -66,14 +57,11 @@ public class ShiftWalkerPlugin extends Plugin
|
||||
private ShiftWalkerInputListener inputListener;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
private MenuManager menuManager;
|
||||
|
||||
@Inject
|
||||
private KeyManager keyManager;
|
||||
|
||||
@Setter
|
||||
private boolean hotKeyPressed = false;
|
||||
|
||||
@Provides
|
||||
ShiftWalkerConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
@@ -97,121 +85,17 @@ public class ShiftWalkerPlugin extends Plugin
|
||||
{
|
||||
if (!event.isFocused())
|
||||
{
|
||||
hotKeyPressed = false;
|
||||
stopPrioritizing();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when a new menu entry was added.
|
||||
*
|
||||
* @param event {@link MenuEntryAdded}.
|
||||
*/
|
||||
@Subscribe
|
||||
public void onMenuEntryAdded(MenuEntryAdded event)
|
||||
void startPrioritizing()
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN || !hotKeyPressed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String pOptionToReplace = Text.removeTags(event.getOption()).toUpperCase();
|
||||
|
||||
//If the option is already to walk there, or cancel we don't need to swap it with anything
|
||||
if (pOptionToReplace.equals(CANCEL) || pOptionToReplace.equals(WALK_HERE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String target = Text.removeTags(event.getTarget().toUpperCase());
|
||||
|
||||
if (config.shiftWalkEverything())
|
||||
{
|
||||
//swap(pOptionToReplace); //Swap everything with walk here
|
||||
stripEntries();
|
||||
}
|
||||
else if (config.shiftWalkBoxTraps() && ShiftWalkerGroups.BOX_TRAP_TARGETS.contains(target)
|
||||
&& ShiftWalkerGroups.BOX_TRAP_KEYWORDS.contains(pOptionToReplace))
|
||||
{
|
||||
//swap(pOptionToReplace); //Swap only on box traps
|
||||
stripEntries();
|
||||
}
|
||||
else if (config.shiftWalkAttackOption() && ShiftWalkerGroups.ATTACK_OPTIONS_KEYWORDS.contains(pOptionToReplace))
|
||||
{
|
||||
//swap(pOptionToReplace); //Swap on everything that has an attack keyword as the first option
|
||||
stripEntries();
|
||||
}
|
||||
menuManager.addPriorityEntry(WALK_HERE, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip everything except "Walk here"
|
||||
* Other way was unconventional because if there was multiple targets in the menu entry it wouldn't swap correctly
|
||||
*/
|
||||
private void stripEntries()
|
||||
void stopPrioritizing()
|
||||
{
|
||||
MenuEntry walkkHereEntry = null;
|
||||
|
||||
for (MenuEntry entry : client.getMenuEntries())
|
||||
{
|
||||
if ("Walk here".equals(entry.getOption()))
|
||||
{
|
||||
walkkHereEntry = entry;
|
||||
}
|
||||
}
|
||||
if (walkkHereEntry != null)
|
||||
{
|
||||
MenuEntry[] newEntries = new MenuEntry[1];
|
||||
newEntries[0] = walkkHereEntry;
|
||||
client.setMenuEntries(newEntries);
|
||||
}
|
||||
menuManager.removePriorityEntry(WALK_HERE, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps menu entries if the entries could be found. This places Walk Here where the top level menu option was.
|
||||
*
|
||||
* @param pOptionToReplace The String containing the Menu Option that needs to be replaced. IE: "Attack", "Chop Down".
|
||||
*/
|
||||
private void swap(String pOptionToReplace) // Swap isn't currently used, and I don't know what's going on here so leaving for now
|
||||
{
|
||||
MenuEntry[] entries = client.getMenuEntries();
|
||||
|
||||
Integer walkHereEntry = searchIndex(entries, WALK_HERE);
|
||||
Integer entryToReplace = searchIndex(entries, pOptionToReplace);
|
||||
|
||||
if (walkHereEntry != null
|
||||
&& entryToReplace != null)
|
||||
{
|
||||
MenuEntry walkHereMenuEntry = entries[walkHereEntry];
|
||||
entries[walkHereEntry] = entries[entryToReplace];
|
||||
entries[entryToReplace] = walkHereMenuEntry;
|
||||
|
||||
client.setMenuEntries(entries);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the index of the menu that contains the verbiage we are looking for.
|
||||
*
|
||||
* @param pMenuEntries The list of {@link MenuEntry}s.
|
||||
* @param pMenuEntryToSearchFor The Option in the menu to search for.
|
||||
* @return The index location or null if it was not found.
|
||||
*/
|
||||
private Integer searchIndex(MenuEntry[] pMenuEntries, String pMenuEntryToSearchFor)
|
||||
{
|
||||
Integer indexLocation = 0;
|
||||
|
||||
for (MenuEntry menuEntry : pMenuEntries)
|
||||
{
|
||||
String entryOption = Text.removeTags(menuEntry.getOption()).toUpperCase();
|
||||
|
||||
if (entryOption.equals(pMenuEntryToSearchFor))
|
||||
{
|
||||
return indexLocation;
|
||||
}
|
||||
|
||||
indexLocation++;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user