menuentryswapper: add checks to ensure when a hotkey is released, swaps get removed. (#1450)

* menuentryswapper: add checks to ensure when a hotkey is released, swaps get removed.

* menuentryswapper: convert priority entry splitter to a list rather than map.
This commit is contained in:
Ganom
2019-08-25 16:18:30 -04:00
committed by GitHub
parent 9d591d4265
commit b885b0a3f8
7 changed files with 297 additions and 216 deletions

View File

@@ -1023,6 +1023,11 @@ public interface Client extends GameShell
*/ */
int getKeyboardIdleTicks(); int getKeyboardIdleTicks();
/**
* Returns an array of booleans relating to keys pressed.
*/
boolean[] getPressedKeys();
/** /**
* Changes how game behaves based on memory mode. Low memory mode skips * Changes how game behaves based on memory mode. Low memory mode skips
* drawing of all floors and renders ground textures in low quality. * drawing of all floors and renders ground textures in low quality.
@@ -1755,4 +1760,4 @@ public interface Client extends GameShell
* Returns the max item index + 1 from cache * Returns the max item index + 1 from cache
*/ */
int getItemCount(); int getItemCount();
} }

View File

@@ -30,6 +30,7 @@ package net.runelite.client.plugins.menuentryswapper;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Keybind;
import net.runelite.client.plugins.menuentryswapper.util.BurningAmuletMode; import net.runelite.client.plugins.menuentryswapper.util.BurningAmuletMode;
import net.runelite.client.plugins.menuentryswapper.util.CharterOption; import net.runelite.client.plugins.menuentryswapper.util.CharterOption;
import net.runelite.client.plugins.menuentryswapper.util.CombatBraceletMode; import net.runelite.client.plugins.menuentryswapper.util.CombatBraceletMode;
@@ -349,12 +350,24 @@ public interface MenuEntrySwapperConfig extends Config
// Miscellaneous // Miscellaneous
//------------------------------------------------------------// //------------------------------------------------------------//
@ConfigItem(
keyName = "hotkeyMod",
name = "Hotkey for Swaps",
description = "Set this hotkey to do custom swaps on hotkeys.",
position = 0,
group = "Miscellaneous"
)
default Keybind hotkeyMod()
{
return Keybind.SHIFT;
}
@ConfigItem( @ConfigItem(
keyName = "customSwaps", keyName = "customSwaps",
name = "Custom Swaps", name = "Custom Swaps",
description = "Add custom swaps here, 1 per line. Syntax: option,target:priority" + description = "Add custom swaps here, 1 per line. Syntax: option,target:priority" +
"<br>Note that the higher your set the priority, the more it will overtake over swaps.", "<br>Note that the higher your set the priority, the more it will overtake over swaps.",
position = 0, position = 1,
group = "Miscellaneous", group = "Miscellaneous",
parse = true, parse = true,
clazz = CustomSwapParse.class, clazz = CustomSwapParse.class,
@@ -367,11 +380,11 @@ public interface MenuEntrySwapperConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "shiftCustomSwaps", keyName = "shiftCustomSwaps",
name = "Shift Swaps", name = "Hotkey Swaps",
description = "Add custom swaps here that will only be activated when you press shift." + description = "Add custom swaps here that will only be activated when you press your hotkey." +
"<br>1 per line. Syntax: option,target:priority" + "<br>1 per line. Syntax: option,target:priority" +
"<br>Note that the higher your set the priority, the more it will overtake over swaps.", "<br>Note that the higher your set the priority, the more it will overtake over swaps.",
position = 1, position = 2,
group = "Miscellaneous", group = "Miscellaneous",
parse = true, parse = true,
clazz = CustomSwapParse.class, clazz = CustomSwapParse.class,
@@ -1734,4 +1747,4 @@ public interface MenuEntrySwapperConfig extends Config
{ {
return "cure other, energy transfer, heal other, vengeance other"; return "cure other, energy transfer, heal other, vengeance other";
} }
} }

View File

@@ -44,14 +44,16 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Setter;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.InventoryID; import net.runelite.api.InventoryID;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.MenuEntry;
import net.runelite.api.MenuOpcode; import net.runelite.api.MenuOpcode;
import static net.runelite.api.MenuOpcode.MENU_ACTION_DEPRIORITIZE_OFFSET; import static net.runelite.api.MenuOpcode.MENU_ACTION_DEPRIORITIZE_OFFSET;
import static net.runelite.api.MenuOpcode.WALK; import static net.runelite.api.MenuOpcode.WALK;
import net.runelite.api.MenuEntry;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
@@ -60,12 +62,14 @@ import net.runelite.api.WorldType;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ClientTick; import net.runelite.api.events.ClientTick;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOpened; import net.runelite.api.events.MenuOpened;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.Keybind;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
import net.runelite.client.menus.AbstractComparableEntry; import net.runelite.client.menus.AbstractComparableEntry;
@@ -99,6 +103,7 @@ import net.runelite.client.plugins.menuentryswapper.util.SlayerRingMode;
import net.runelite.client.plugins.menuentryswapper.util.XericsTalismanMode; import net.runelite.client.plugins.menuentryswapper.util.XericsTalismanMode;
import net.runelite.client.plugins.pvptools.PvpToolsConfig; import net.runelite.client.plugins.pvptools.PvpToolsConfig;
import net.runelite.client.plugins.pvptools.PvpToolsPlugin; import net.runelite.client.plugins.pvptools.PvpToolsPlugin;
import net.runelite.client.util.HotkeyListener;
import static net.runelite.client.util.MenuUtil.swap; import static net.runelite.client.util.MenuUtil.swap;
import net.runelite.client.util.MiscUtils; import net.runelite.client.util.MiscUtils;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@@ -116,8 +121,10 @@ import org.apache.commons.lang3.ArrayUtils;
public class MenuEntrySwapperPlugin extends Plugin public class MenuEntrySwapperPlugin extends Plugin
{ {
private static final String CONFIG_GROUP = "shiftclick"; private static final String CONFIG_GROUP = "shiftclick";
private static final String SHIFT = "menuentryswapper shift"; private static final String HOTKEY = "menuentryswapper hotkey";
private static final String CONTROL = "menuentryswapper control"; private static final String CONTROL = "menuentryswapper control";
private static final String HOTKEY_CHECK = "menuentryswapper hotkey check";
private static final String CONTROL_CHECK = "menuentryswapper control check";
private static final int PURO_PURO_REGION_ID = 10307; private static final int PURO_PURO_REGION_ID = 10307;
private static final Set<MenuOpcode> NPC_MENU_TYPES = ImmutableSet.of( private static final Set<MenuOpcode> NPC_MENU_TYPES = ImmutableSet.of(
MenuOpcode.NPC_FIRST_OPTION, MenuOpcode.NPC_SECOND_OPTION, MenuOpcode.NPC_THIRD_OPTION, MenuOpcode.NPC_FIRST_OPTION, MenuOpcode.NPC_SECOND_OPTION, MenuOpcode.NPC_THIRD_OPTION,
@@ -141,8 +148,6 @@ public class MenuEntrySwapperPlugin extends Plugin
@Inject @Inject
private KeyManager keyManager; private KeyManager keyManager;
@Inject @Inject
private ShiftClickInputListener inputListener;
@Inject
private EventBus eventBus; private EventBus eventBus;
@Inject @Inject
private PvpToolsPlugin pvpTools; private PvpToolsPlugin pvpTools;
@@ -158,6 +163,10 @@ public class MenuEntrySwapperPlugin extends Plugin
private boolean buildingMode; private boolean buildingMode;
private boolean inTobRaid = false; private boolean inTobRaid = false;
private boolean inCoxRaid = false; private boolean inCoxRaid = false;
@Setter(AccessLevel.PRIVATE)
private boolean hotkeyActive;
@Setter(AccessLevel.PRIVATE)
private boolean controlActive;
private final Map<AbstractComparableEntry, Integer> customSwaps = new HashMap<>(); private final Map<AbstractComparableEntry, Integer> customSwaps = new HashMap<>();
private final Map<AbstractComparableEntry, Integer> customShiftSwaps = new HashMap<>(); private final Map<AbstractComparableEntry, Integer> customShiftSwaps = new HashMap<>();
private final Map<AbstractComparableEntry, AbstractComparableEntry> dePrioSwaps = new HashMap<>(); private final Map<AbstractComparableEntry, AbstractComparableEntry> dePrioSwaps = new HashMap<>();
@@ -286,6 +295,7 @@ public class MenuEntrySwapperPlugin extends Plugin
private boolean swapTrade; private boolean swapTrade;
private boolean swapTravel; private boolean swapTravel;
private boolean swapWildernessLever; private boolean swapWildernessLever;
private Keybind hotkeyMod;
@Provides @Provides
MenuEntrySwapperConfig provideConfig(ConfigManager configManager) MenuEntrySwapperConfig provideConfig(ConfigManager configManager)
@@ -302,7 +312,8 @@ public class MenuEntrySwapperPlugin extends Plugin
addSwaps(); addSwaps();
loadConstructionItems(); loadConstructionItems();
loadCustomSwaps(config.customSwaps(), customSwaps); loadCustomSwaps(config.customSwaps(), customSwaps);
keyManager.registerKeyListener(inputListener); keyManager.registerKeyListener(ctrlHotkey);
keyManager.registerKeyListener(hotkey);
if (client.getGameState() == GameState.LOGGED_IN) if (client.getGameState() == GameState.LOGGED_IN)
{ {
setCastOptions(true); setCastOptions(true);
@@ -316,7 +327,8 @@ public class MenuEntrySwapperPlugin extends Plugin
loadCustomSwaps("", customSwaps); // Removes all custom swaps loadCustomSwaps("", customSwaps); // Removes all custom swaps
removeSwaps(); removeSwaps();
keyManager.unregisterKeyListener(inputListener); keyManager.unregisterKeyListener(ctrlHotkey);
keyManager.unregisterKeyListener(hotkey);
if (client.getGameState() == GameState.LOGGED_IN) if (client.getGameState() == GameState.LOGGED_IN)
{ {
resetCastOptions(); resetCastOptions();
@@ -330,6 +342,16 @@ public class MenuEntrySwapperPlugin extends Plugin
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged); eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
eventBus.subscribe(MenuOpened.class, this, this::onMenuOpened); eventBus.subscribe(MenuOpened.class, this, this::onMenuOpened);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded); eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(FocusChanged.class, this, this::onFocusChanged);
}
private void onFocusChanged(FocusChanged event)
{
if (!event.isFocused())
{
stopControl();
stopHotkey();
}
} }
private void onConfigChanged(ConfigChanged event) private void onConfigChanged(ConfigChanged event)
@@ -714,12 +736,19 @@ public class MenuEntrySwapperPlugin extends Plugin
private void addSwaps() private void addSwaps()
{ {
final Map<String, String> tmp = NEWLINE_SPLITTER.withKeyValueSeparator(',').split(config.prioEntry()); final List<String> tmp = NEWLINE_SPLITTER.splitToList(config.prioEntry());
for (Map.Entry<String, String> str : tmp.entrySet()) for (String str : tmp)
{ {
final AbstractComparableEntry a = newBaseComparableEntry("", str.getValue(), -1, -1, false, true); String[] strings = str.split(",");
final AbstractComparableEntry b = newBaseComparableEntry(str.getKey(), "", -1, -1, false, false);
if (strings.length <= 1)
{
continue;
}
final AbstractComparableEntry a = newBaseComparableEntry("", strings[1], -1, -1, false, true);
final AbstractComparableEntry b = newBaseComparableEntry(strings[0], "", -1, -1, false, false);
dePrioSwaps.put(a, b); dePrioSwaps.put(a, b);
menuManager.addSwap(a, b); menuManager.addSwap(a, b);
} }
@@ -1436,37 +1465,58 @@ public class MenuEntrySwapperPlugin extends Plugin
} }
} }
void startShift() private void startHotkey()
{ {
eventBus.subscribe(ClientTick.class, SHIFT, this::addShift); eventBus.subscribe(ClientTick.class, HOTKEY, this::addHotkey);
eventBus.subscribe(ClientTick.class, HOTKEY_CHECK, this::hotkeyCheck);
} }
private void addShift(ClientTick event) private void addHotkey(ClientTick event)
{ {
loadCustomSwaps(this.configCustomShiftSwaps, customShiftSwaps); loadCustomSwaps(this.configCustomShiftSwaps, customShiftSwaps);
if (!this.swapClimbUpDown) if (this.swapClimbUpDown)
{ {
return; menuManager.addPriorityEntry("climb-up").setPriority(100);
} }
menuManager.addPriorityEntry("climb-up").setPriority(100); eventBus.unregister(HOTKEY);
eventBus.unregister(SHIFT);
} }
void stopShift() private void stopHotkey()
{ {
eventBus.subscribe(ClientTick.class, SHIFT, this::remShift); eventBus.subscribe(ClientTick.class, HOTKEY, this::removeHotkey);
} }
private void remShift(ClientTick event) private void removeHotkey(ClientTick event)
{ {
menuManager.removePriorityEntry("climb-up"); menuManager.removePriorityEntry("climb-up");
loadCustomSwaps("", customShiftSwaps); loadCustomSwaps("", customShiftSwaps);
eventBus.unregister(SHIFT); eventBus.unregister(HOTKEY);
} }
void startControl() private void hotkeyCheck(ClientTick event)
{
if (hotkeyActive)
{
int i = 0;
for (boolean bol : client.getPressedKeys())
{
if (bol)
{
i++;
}
}
if (i == 0)
{
stopHotkey();
setHotkeyActive(false);
eventBus.unregister(HOTKEY_CHECK);
}
}
}
private void startControl()
{ {
if (!this.swapClimbUpDown) if (!this.swapClimbUpDown)
{ {
@@ -1474,6 +1524,7 @@ public class MenuEntrySwapperPlugin extends Plugin
} }
eventBus.subscribe(ClientTick.class, CONTROL, this::addControl); eventBus.subscribe(ClientTick.class, CONTROL, this::addControl);
eventBus.subscribe(ClientTick.class, CONTROL_CHECK, this::controlCheck);
} }
private void addControl(ClientTick event) private void addControl(ClientTick event)
@@ -1482,17 +1533,38 @@ public class MenuEntrySwapperPlugin extends Plugin
eventBus.unregister(CONTROL); eventBus.unregister(CONTROL);
} }
void stopControl() private void stopControl()
{ {
eventBus.subscribe(ClientTick.class, CONTROL, this::remControl); eventBus.subscribe(ClientTick.class, CONTROL, this::removeControl);
} }
private void remControl(ClientTick event) private void removeControl(ClientTick event)
{ {
menuManager.removePriorityEntry("climb-down"); menuManager.removePriorityEntry("climb-down");
eventBus.unregister(CONTROL); eventBus.unregister(CONTROL);
} }
private void controlCheck(ClientTick event)
{
if (controlActive)
{
int i = 0;
for (boolean bol : client.getPressedKeys())
{
if (bol)
{
i++;
}
}
if (i == 0)
{
stopControl();
setControlActive(false);
eventBus.unregister(CONTROL_CHECK);
}
}
}
private void setCastOptions(boolean force) private void setCastOptions(boolean force)
{ {
clientThread.invoke(() -> clientThread.invoke(() ->
@@ -1548,130 +1620,131 @@ public class MenuEntrySwapperPlugin extends Plugin
private void updateConfig() private void updateConfig()
{ {
this.getWithdrawOne = config.getWithdrawOne(); this.charterOption = config.charterOption();
this.getWithdrawOneItems = config.getWithdrawOneItems(); this.configCustomShiftSwaps = config.shiftCustomSwaps();
this.configCustomSwaps = config.customSwaps();
this.constructionCapeMode = config.constructionCapeMode();
this.getBurningAmulet = config.getBurningAmulet();
this.getBurningAmuletMode = config.getBurningAmuletMode();
this.getBuyFiftyItems = config.getBuyFiftyItems();
this.getBuyFiveItems = config.getBuyFiveItems();
this.getBuyOneItems = config.getBuyOneItems();
this.getBuyTenItems = config.getBuyTenItems();
this.getCombatBracelet = config.getCombatBracelet();
this.getCombatBraceletMode = config.getCombatBraceletMode();
this.getConstructionMode = config.getConstructionMode();
this.getDigsitePendant = config.getDigsitePendant();
this.getDigsitePendantMode = config.getDigsitePendantMode();
this.getDuelingRing = config.getDuelingRing();
this.getDuelingRingMode = config.getDuelingRingMode();
this.getEasyConstruction = config.getEasyConstruction();
this.getGamesNecklace = config.getGamesNecklace();
this.getGamesNecklaceMode = config.getGamesNecklaceMode();
this.getGlory = config.getGlory();
this.getGloryMode = config.getGloryMode();
this.getNecklaceofPassage = config.getNecklaceofPassage();
this.getNecklaceofPassageMode = config.getNecklaceofPassageMode();
this.getRemoveObjects = config.getRemoveObjects();
this.getRemovedObjects = config.getRemovedObjects();
this.getRingofWealth = config.getRingofWealth();
this.getRingofWealthMode = config.getRingofWealthMode();
this.getSellFiftyItems = config.getSellFiftyItems();
this.getSellFiveItems = config.getSellFiveItems();
this.getSellOneItems = config.getSellOneItems();
this.getSellTenItems = config.getSellTenItems();
this.getSkillsNecklace = config.getSkillsNecklace();
this.getSkillsNecklaceMode = config.getSkillsNecklaceMode();
this.getSlayerRing = config.getSlayerRing();
this.getSlayerRingMode = config.getSlayerRingMode();
this.getSwapArdougneCape = config.getSwapArdougneCape();
this.getSwapBuyFifty = config.getSwapBuyFifty();
this.getSwapBuyFive = config.getSwapBuyFive();
this.getSwapBuyOne = config.getSwapBuyOne();
this.getSwapBuyTen = config.getSwapBuyTen();
this.getSwapConstructionCape = config.getSwapConstructionCape();
this.getSwapCraftingCape = config.getSwapCraftingCape();
this.getSwapExplorersRing = config.getSwapExplorersRing();
this.getSwapMagicCape = config.getSwapMagicCape();
this.getSwapPuro = config.getSwapPuro();
this.getSwapSawmill = config.getSwapSawmill();
this.getSwapSawmillPlanks = config.getSwapSawmillPlanks();
this.getSwapSellFifty = config.getSwapSellFifty();
this.getSwapSellFive = config.getSwapSellFive();
this.getSwapSellOne = config.getSwapSellOne();
this.getSwapSellTen = config.getSwapSellTen();
this.getSwapTanning = config.getSwapTanning();
this.getWithdrawAll = config.getWithdrawAll();
this.getWithdrawAllItems = config.getWithdrawAllItems();
this.getWithdrawFive = config.getWithdrawFive(); this.getWithdrawFive = config.getWithdrawFive();
this.getWithdrawFiveItems = config.getWithdrawFiveItems(); this.getWithdrawFiveItems = config.getWithdrawFiveItems();
this.getWithdrawOne = config.getWithdrawOne();
this.getWithdrawOneItems = config.getWithdrawOneItems();
this.getWithdrawTen = config.getWithdrawTen(); this.getWithdrawTen = config.getWithdrawTen();
this.getWithdrawTenItems = config.getWithdrawTenItems(); this.getWithdrawTenItems = config.getWithdrawTenItems();
this.getWithdrawX = config.getWithdrawX(); this.getWithdrawX = config.getWithdrawX();
this.getWithdrawXAmount = config.getWithdrawXAmount(); this.getWithdrawXAmount = config.getWithdrawXAmount();
this.getWithdrawXItems = config.getWithdrawXItems(); this.getWithdrawXItems = config.getWithdrawXItems();
this.getWithdrawAll = config.getWithdrawAll();
this.getWithdrawAllItems = config.getWithdrawAllItems();
this.swapMax = config.swapMax();
this.maxMode = config.maxMode();
this.getSwapArdougneCape = config.getSwapArdougneCape();
this.getSwapConstructionCape = config.getSwapConstructionCape();
this.constructionCapeMode = config.constructionCapeMode();
this.getSwapCraftingCape = config.getSwapCraftingCape();
this.getSwapMagicCape = config.getSwapMagicCape();
this.getSwapExplorersRing = config.getSwapExplorersRing();
this.swapAdmire = config.swapAdmire();
this.swapQuestCape = config.swapQuestCape();
this.questCapeMode = config.questCapeMode();
this.configCustomSwaps = config.customSwaps();
this.configCustomShiftSwaps = config.shiftCustomSwaps();
this.swapCoalBag = config.swapCoalBag();
this.swapBirdhouseEmpty = config.swapBirdhouseEmpty();
this.swapBones = config.swapBones();
this.swapChase = config.swapChase();
this.swapHarpoon = config.swapHarpoon();
this.swapOccultMode = config.swapOccultMode();
this.swapHomePortalMode = config.swapHomePortalMode();
this.swapPrivate = config.swapPrivate();
this.swapPick = config.swapPick();
this.swapQuick = config.swapQuick();
this.swapBoxTrap = config.swapBoxTrap();
this.rockCake = config.rockCake();
this.swapRogueschests = config.swapRogueschests();
this.swapClimbUpDown = config.swapClimbUpDown();
this.swapStun = config.swapStun();
this.swapSearch = config.swapSearch();
this.swapHardWoodGrove = config.swapHardWoodGrove();
this.getRemoveObjects = config.getRemoveObjects();
this.getRemovedObjects = config.getRemovedObjects();
this.swapImps = config.swapImps();
this.charterOption = config.charterOption();
this.getSwapBuyOne = config.getSwapBuyOne();
this.getBuyOneItems = config.getBuyOneItems();
this.getSwapBuyFive = config.getSwapBuyFive();
this.getBuyFiveItems = config.getBuyFiveItems();
this.getSwapBuyTen = config.getSwapBuyTen();
this.getBuyTenItems = config.getBuyTenItems();
this.getSwapBuyFifty = config.getSwapBuyFifty();
this.getBuyFiftyItems = config.getBuyFiftyItems();
this.getSwapSellOne = config.getSwapSellOne();
this.getSellOneItems = config.getSellOneItems();
this.getSwapSellFive = config.getSwapSellFive();
this.getSellFiveItems = config.getSellFiveItems();
this.getSwapSellTen = config.getSwapSellTen();
this.getSellTenItems = config.getSellTenItems();
this.getSwapSellFifty = config.getSwapSellFifty();
this.getSellFiftyItems = config.getSellFiftyItems();
this.getEasyConstruction = config.getEasyConstruction();
this.getSwapTanning = config.getSwapTanning();
this.getSwapSawmill = config.getSwapSawmill();
this.getSwapSawmillPlanks = config.getSwapSawmillPlanks();
this.getSwapPuro = config.getSwapPuro();
this.swapAssignment = config.swapAssignment();
this.swapBankExchange = config.swapBankExchange();
this.swapContract = config.swapContract();
this.swapInteract = config.swapInteract();
this.swapPickpocket = config.swapPickpocket();
this.swapPay = config.swapPay();
this.swapAbyssTeleport = config.swapAbyssTeleport();
this.swapTrade = config.swapTrade();
this.swapTravel = config.swapTravel();
this.swapMinigame = config.swapMinigame();
this.swapPlank = config.swapPlank();
this.swapMetamorphosis = config.swapMetamorphosis();
this.swapEnchant = config.swapEnchant();
this.swapFairyRingMode = config.swapFairyRingMode();
this.swapObeliskMode = config.swapObeliskMode();
this.swapTeleportItem = config.swapTeleportItem();
this.swapWildernessLever = config.swapWildernessLever();
this.swapNexus = config.swapNexus();
this.getGamesNecklace = config.getGamesNecklace();
this.getGamesNecklaceMode = config.getGamesNecklaceMode();
this.getDuelingRing = config.getDuelingRing();
this.getDuelingRingMode = config.getDuelingRingMode();
this.getGlory = config.getGlory();
this.getGloryMode = config.getGloryMode();
this.getSkillsNecklace = config.getSkillsNecklace();
this.getSkillsNecklaceMode = config.getSkillsNecklaceMode();
this.getNecklaceofPassage = config.getNecklaceofPassage();
this.getNecklaceofPassageMode = config.getNecklaceofPassageMode();
this.getDigsitePendant = config.getDigsitePendant();
this.getDigsitePendantMode = config.getDigsitePendantMode();
this.getCombatBracelet = config.getCombatBracelet();
this.getCombatBraceletMode = config.getCombatBraceletMode();
this.getBurningAmulet = config.getBurningAmulet();
this.getBurningAmuletMode = config.getBurningAmuletMode();
this.getConstructionMode = config.getConstructionMode();
this.getXericsTalisman = config.getXericsTalisman(); this.getXericsTalisman = config.getXericsTalisman();
this.getXericsTalismanMode = config.getXericsTalismanMode(); this.getXericsTalismanMode = config.getXericsTalismanMode();
this.getRingofWealth = config.getRingofWealth();
this.getRingofWealthMode = config.getRingofWealthMode();
this.getSlayerRing = config.getSlayerRing();
this.getSlayerRingMode = config.getSlayerRingMode();
this.hideExamine = config.hideExamine();
this.hideTradeWith = config.hideTradeWith();
this.hideReport = config.hideReport();
this.hideLookup = config.hideLookup();
this.hideNet = config.hideNet();
this.hideBait = config.hideBait(); this.hideBait = config.hideBait();
this.hideDestroyRunepouch = config.hideDestroyRunepouch();
this.hideDestroyCoalbag = config.hideDestroyCoalbag();
this.hideDestroyHerbsack = config.hideDestroyHerbsack();
this.hideDestroyBoltpouch = config.hideDestroyBoltpouch();
this.hideDestroyLootingBag = config.hideDestroyLootingBag();
this.hideDestroyGembag = config.hideDestroyGembag();
this.hideDropRunecraftingPouch = config.hideDropRunecraftingPouch();
this.hideCastToB = config.hideCastToB();
this.hideCastIgnoredToB = Sets.newHashSet(Text.fromCSV(config.hideCastIgnoredToB().toLowerCase()));
this.hideCastCoX = config.hideCastCoX(); this.hideCastCoX = config.hideCastCoX();
this.hideCastIgnoredCoX = Sets.newHashSet(Text.fromCSV(config.hideCastIgnoredCoX().toLowerCase())); this.hideCastIgnoredCoX = Sets.newHashSet(Text.fromCSV(config.hideCastIgnoredCoX().toLowerCase()));
this.hideCastIgnoredToB = Sets.newHashSet(Text.fromCSV(config.hideCastIgnoredToB().toLowerCase()));
this.hideCastToB = config.hideCastToB();
this.hideDestroyBoltpouch = config.hideDestroyBoltpouch();
this.hideDestroyCoalbag = config.hideDestroyCoalbag();
this.hideDestroyGembag = config.hideDestroyGembag();
this.hideDestroyHerbsack = config.hideDestroyHerbsack();
this.hideDestroyLootingBag = config.hideDestroyLootingBag();
this.hideDestroyRunepouch = config.hideDestroyRunepouch();
this.hideDropRunecraftingPouch = config.hideDropRunecraftingPouch();
this.hideExamine = config.hideExamine();
this.hideLookup = config.hideLookup();
this.hideNet = config.hideNet();
this.hideReport = config.hideReport();
this.hideTradeWith = config.hideTradeWith();
this.hotkeyMod = config.hotkeyMod();
this.maxMode = config.maxMode();
this.questCapeMode = config.questCapeMode();
this.rockCake = config.rockCake();
this.swapAbyssTeleport = config.swapAbyssTeleport();
this.swapAdmire = config.swapAdmire();
this.swapAssignment = config.swapAssignment();
this.swapBankExchange = config.swapBankExchange();
this.swapBirdhouseEmpty = config.swapBirdhouseEmpty();
this.swapBones = config.swapBones();
this.swapBoxTrap = config.swapBoxTrap();
this.swapChase = config.swapChase();
this.swapClimbUpDown = config.swapClimbUpDown();
this.swapCoalBag = config.swapCoalBag();
this.swapContract = config.swapContract();
this.swapEnchant = config.swapEnchant();
this.swapFairyRingMode = config.swapFairyRingMode();
this.swapHardWoodGrove = config.swapHardWoodGrove();
this.swapHarpoon = config.swapHarpoon();
this.swapHomePortalMode = config.swapHomePortalMode();
this.swapImps = config.swapImps();
this.swapInteract = config.swapInteract();
this.swapMax = config.swapMax();
this.swapMetamorphosis = config.swapMetamorphosis();
this.swapMinigame = config.swapMinigame();
this.swapNexus = config.swapNexus();
this.swapObeliskMode = config.swapObeliskMode();
this.swapOccultMode = config.swapOccultMode();
this.swapPay = config.swapPay();
this.swapPick = config.swapPick();
this.swapPickpocket = config.swapPickpocket();
this.swapPlank = config.swapPlank();
this.swapPrivate = config.swapPrivate();
this.swapQuestCape = config.swapQuestCape();
this.swapQuick = config.swapQuick();
this.swapRogueschests = config.swapRogueschests();
this.swapSearch = config.swapSearch();
this.swapStun = config.swapStun();
this.swapTeleportItem = config.swapTeleportItem();
this.swapTrade = config.swapTrade();
this.swapTravel = config.swapTravel();
this.swapWildernessLever = config.swapWildernessLever();
} }
/** /**
@@ -1757,4 +1830,38 @@ public class MenuEntrySwapperPlugin extends Plugin
.collect(Collectors.joining("\n")) .collect(Collectors.joining("\n"))
); );
} }
private final HotkeyListener hotkey = new HotkeyListener(() -> this.hotkeyMod)
{
@Override
public void hotkeyPressed()
{
startHotkey();
setHotkeyActive(true);
}
@Override
public void hotkeyReleased()
{
stopHotkey();
setHotkeyActive(false);
}
};
private final HotkeyListener ctrlHotkey = new HotkeyListener(() -> Keybind.CTRL)
{
@Override
public void hotkeyPressed()
{
startControl();
setControlActive(true);
}
@Override
public void hotkeyReleased()
{
stopControl();
setControlActive(false);
}
};
} }

View File

@@ -25,8 +25,10 @@
package net.runelite.client.plugins.menuentryswapper; package net.runelite.client.plugins.menuentryswapper;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import java.util.Map; import java.util.List;
import javax.inject.Singleton;
@Singleton
public class PrioParse public class PrioParse
{ {
public static boolean parse(String value) public static boolean parse(String value)
@@ -48,7 +50,17 @@ public class PrioParse
.omitEmptyStrings() .omitEmptyStrings()
.trimResults(); .trimResults();
final Map<String, String> tmp = NEWLINE_SPLITTER.withKeyValueSeparator(',').split(sb); final List<String> tmp = NEWLINE_SPLITTER.splitToList(sb);
for (String s : tmp)
{
final String[] strings = s.split(",");
if (strings.length <= 1)
{
return false;
}
}
return tmp.size() > 0; return tmp.size() > 0;
} }
@@ -57,4 +69,4 @@ public class PrioParse
return false; return false;
} }
} }
} }

View File

@@ -1,68 +0,0 @@
/*
* Copyright (c) 2018, Kamiel
* 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.menuentryswapper;
import java.awt.event.KeyEvent;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.client.input.KeyListener;
@Singleton
class ShiftClickInputListener implements KeyListener
{
@Inject
private MenuEntrySwapperPlugin plugin;
@Override
public void keyTyped(KeyEvent event)
{
}
@Override
public void keyPressed(KeyEvent event)
{
if (event.getKeyCode() == KeyEvent.VK_SHIFT)
{
plugin.startShift();
}
if (event.getKeyCode() == KeyEvent.VK_CONTROL)
{
plugin.startControl();
}
}
@Override
public void keyReleased(KeyEvent event)
{
if (event.getKeyCode() == KeyEvent.VK_SHIFT)
{
plugin.stopShift();
}
if (event.getKeyCode() == KeyEvent.VK_CONTROL)
{
plugin.stopControl();
}
}
}

View File

@@ -73,6 +73,10 @@ public abstract class HotkeyListener implements KeyListener
{ {
if (keybind.get().matches(e)) if (keybind.get().matches(e))
{ {
if (isPressed)
{
hotkeyReleased();
}
isPressed = false; isPressed = false;
isConsumingTyped = false; isConsumingTyped = false;
} }
@@ -81,4 +85,8 @@ public abstract class HotkeyListener implements KeyListener
public void hotkeyPressed() public void hotkeyPressed()
{ {
} }
public void hotkeyReleased()
{
}
} }

View File

@@ -29,11 +29,11 @@
package net.runelite.rs.api; package net.runelite.rs.api;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Map;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Sprite; import net.runelite.api.Sprite;
import net.runelite.api.World; import net.runelite.api.World;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import java.util.Map;
import net.runelite.mapping.Construct; import net.runelite.mapping.Construct;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
@@ -597,6 +597,10 @@ public interface RSClient extends RSGameShell, Client
@Override @Override
int getKeyboardIdleTicks(); int getKeyboardIdleTicks();
@Import("KeyHandler_pressedKeys")
@Override
boolean[] getPressedKeys();
@Import("isLowDetail") @Import("isLowDetail")
void setLowMemory(boolean lowMemory); void setLowMemory(boolean lowMemory);
@@ -1046,4 +1050,4 @@ public interface RSClient extends RSGameShell, Client
@Import("ItemDefinition_fileCount") @Import("ItemDefinition_fileCount")
int getItemCount(); int getItemCount();
} }