Merge pull request #388 from runelite-extended/menu-modifier

Reworked MenuEntrySwapper to include Easyscape and MenuModifier
This commit is contained in:
Jonathan
2019-05-25 15:52:22 -06:00
committed by GitHub
23 changed files with 1987 additions and 2211 deletions

View File

@@ -1,893 +0,0 @@
/*
* Copyright (c) 2018, Alan Baumgartner <https://github.com/alanbaumgartner>
* Copyright (c) 2018, https://runelitepl.us
* Copyright (c) 2018, Kyle <https://github.com/kyleeld>
* Copyright (c) 2018, Owain van Brakel <https://github.com/Owain94>
* 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;
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.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;
import net.runelite.client.plugins.easyscape.util.CombatBraceletMode;
import net.runelite.client.plugins.easyscape.util.SlayerRingMode;
import net.runelite.client.plugins.easyscape.util.BurningAmuletMode;
import net.runelite.client.plugins.easyscape.util.XericsTalismanMode;
import net.runelite.client.plugins.easyscape.util.RingOfWealthMode;
@ConfigGroup("easyscape")
public interface EasyscapeConfig extends Config
{
@ConfigItem(
keyName = "withdrawOne",
name = "Withdraw/Deposit One",
description = "",
position = 0,
group = "Banking"
)
default boolean getWithdrawOne()
{
return false;
}
@ConfigItem(
keyName = "withdrawOneItems",
name = "Items",
description = "",
position = 1,
group = "Banking",
hidden = true,
unhide = "withdrawOne"
)
default String getWithdrawOneItems()
{
return "";
}
@ConfigItem(
keyName = "withdrawFive",
name = "Withdraw/Deposit Five",
description = "",
position = 2,
group = "Banking"
)
default boolean getWithdrawFive()
{
return false;
}
@ConfigItem(
keyName = "withdrawFiveItems",
name = "Items",
description = "",
position = 3,
group = "Banking",
hidden = true,
unhide = "withdrawFive"
)
default String getWithdrawFiveItems()
{
return "";
}
@ConfigItem(
keyName = "withdrawTen",
name = "Withdraw/Deposit Ten",
description = "",
position = 4,
group = "Banking"
)
default boolean getWithdrawTen()
{
return false;
}
@ConfigItem(
keyName = "withdrawTenItems",
name = "Items",
description = "",
position = 5,
group = "Banking",
hidden = true,
unhide = "withdrawTen"
)
default String getWithdrawTenItems()
{
return "";
}
@ConfigItem(
keyName = "withdrawX",
name = "Withdraw/Deposit X",
description = "",
position = 6,
group = "Banking"
)
default boolean getWithdrawX()
{
return false;
}
@ConfigItem(
keyName = "withdrawXAmount",
name = "Amount",
description = "",
position = 7,
group = "Banking",
hidden = true,
unhide = "withdrawX"
)
default String getWithdrawXAmount()
{
return "";
}
@ConfigItem(
keyName = "withdrawXItems",
name = "Items",
description = "",
position = 8,
group = "Banking",
hidden = true,
unhide = "withdrawX"
)
default String getWithdrawXItems()
{
return "";
}
@ConfigItem(
keyName = "withdrawAll",
name = "Withdraw/Deposit All",
description = "",
position = 9,
group = "Banking"
)
default boolean getWithdrawAll()
{
return false;
}
@ConfigItem(
keyName = "withdrawAllItems",
name = "Items",
description = "",
position = 10,
group = "Banking",
hidden = true,
unhide = "withdrawAll"
)
default String getWithdrawAllItems()
{
return "";
}
// ----------------------------------------------------------- //
@ConfigItem(
keyName = "removeObjects",
name = "Remove Objects",
description = "Removes interaction with the listed objects.",
position = 12,
group = "Miscellaneous easyscape"
)
default boolean getRemoveObjects()
{
return false;
}
@ConfigItem(
keyName = "removedObjects",
name = "Objects",
description = "Objects listed here will have all interaction be removed.",
position = 13,
group = "Miscellaneous easyscape",
hidden = true,
unhide = "removeObjects"
)
default String getRemovedObjects()
{
return "";
}
// ----------------------------------------------------------- //
@ConfigItem(
keyName = "swapBuyOne",
name = "Swappable Buy One",
description = "",
position = 14,
group = "Shop / stores"
)
default boolean getSwapBuyOne()
{
return false;
}
@ConfigItem(
keyName = "buyOneItems",
name = "Items",
description = "",
position = 15,
group = "Shop / stores",
hidden = true,
unhide = "swapBuyOne"
)
default String getBuyOneItems()
{
return "";
}
@ConfigItem(
keyName = "swapBuyFive",
name = "Swappable Buy Five",
description = "",
position = 16,
group = "Shop / stores"
)
default boolean getSwapBuyFive()
{
return false;
}
@ConfigItem(
keyName = "buyFiveItems",
name = "Items",
description = "",
position = 17,
group = "Shop / stores",
hidden = true,
unhide = "swapBuyFive"
)
default String getBuyFiveItems()
{
return "";
}
@ConfigItem(
keyName = "swapBuyTen",
name = "Swappable Buy Ten",
description = "",
position = 18,
group = "Shop / stores"
)
default boolean getSwapBuyTen()
{
return false;
}
@ConfigItem(
keyName = "buyTenItems",
name = "Items",
description = "",
position = 19,
group = "Shop / stores",
hidden = true,
unhide = "swapBuyTen"
)
default String getBuyTenItems()
{
return "";
}
@ConfigItem(
keyName = "swapBuyFifty",
name = "Swappable Buy Fifty",
description = "",
position = 20,
group = "Shop / stores"
)
default boolean getSwapBuyFifty()
{
return false;
}
@ConfigItem(
keyName = "buyFiftyItems",
name = "Items",
description = "",
position = 21,
group = "Shop / stores",
hidden = true,
unhide = "swapBuyFifty"
)
default String getBuyFiftyItems()
{
return "";
}
@ConfigItem(
keyName = "swapSellOne",
name = "Swappable Sell One",
description = "",
position = 22,
group = "Shop / stores"
)
default boolean getSwapSellOne()
{
return false;
}
@ConfigItem(
keyName = "sellOneItems",
name = "Items",
description = "",
position = 23,
group = "Shop / stores",
hidden = true,
unhide = "swapSellOne"
)
default String getSellOneItems()
{
return "";
}
@ConfigItem(
keyName = "swapSellFive",
name = "Swappable Sell Five",
description = "",
position = 24,
group = "Shop / stores"
)
default boolean getSwapSellFive()
{
return false;
}
@ConfigItem(
keyName = "sellFiveItems",
name = "Items",
description = "",
position = 25,
group = "Shop / stores",
hidden = true,
unhide = "swapSellFive"
)
default String getSellFiveItems()
{
return "";
}
@ConfigItem(
keyName = "swapSellTen",
name = "Swappable Sell Ten",
description = "",
position = 26,
group = "Shop / stores"
)
default boolean getSwapSellTen()
{
return false;
}
@ConfigItem(
keyName = "sellTenItems",
name = "Items",
description = "",
position = 27,
group = "Shop / stores",
hidden = true,
unhide = "swapSellTen"
)
default String getSellTenItems()
{
return "";
}
@ConfigItem(
keyName = "swapSellFifty",
name = "Swappable Sell Fifty",
description = "",
position = 28,
group = "Shop / stores"
)
default boolean getSwapSellFifty()
{
return false;
}
@ConfigItem(
keyName = "sellFiftyItems",
name = "Items",
description = "",
position = 29,
group = "Shop / stores",
hidden = true,
unhide = "swapSellFifty"
)
default String getSellFiftyItems()
{
return "";
}
// ----------------------------------------------------------- //
@ConfigItem(
keyName = "easyConstruction",
name = "Easy Construction",
description = "Makes \"Remove\"/\"Build\" the default option for listed item ID's in build mode.<br>Tip: Use dev tools \"Game Objects\" to find out the ID!",
position = 30,
group = "Miscellaneous swapper"
)
default boolean getEasyConstruction()
{
return false;
}
@ConfigItem(
keyName = "constructionItems",
name = "Construction Items",
description = "Makes \"Remove\"/\"Build\" the default option for listed item ID's in build mode.<br>Tip: Use dev tools \"Game Objects\" to find out the ID, and seperate values with a ','",
position = 31,
group = "Miscellaneous swapper",
hidden = true,
unhide = "easyConstruction"
)
default String getConstructionItems()
{
return "";
}
@ConfigItem(
keyName = "swapSmithing",
name = "Swap Smithing",
description = "Enables swapping of smith-1 and smith-all options.",
position = 32,
group = "Miscellaneous swapper"
)
default boolean getSwapSmithing()
{
return false;
}
@ConfigItem(
keyName = "swapTanning",
name = "Swap Tanning",
description = "Enables swapping of tan-1 and tan-all options.",
position = 33,
group = "Miscellaneous swapper"
)
default boolean getSwapTanning()
{
return false;
}
@ConfigItem(
keyName = "swapSawmill",
name = "Swap Sawmill Operator",
description = "Makes Buy-plank the default option on the sawmill operator.",
position = 34,
group = "Miscellaneous swapper"
)
default boolean getSwapSawmill()
{
return false;
}
@ConfigItem(
keyName = "swapSawmillPlanks",
name = "Swap Buy Planks",
description = "Makes Buy All the default option in buy planks.",
position = 35,
group = "Miscellaneous swapper"
)
default boolean getSwapSawmillPlanks()
{
return false;
}
@ConfigItem(
keyName = "swapPuroPuro",
name = "Swap Puro Puro Wheat",
description = "",
position = 36,
group = "Miscellaneous swapper"
)
default boolean getSwapPuro()
{
return false;
}
// ----------------------------------------------------------- //
@ConfigItem(
keyName = "swapGamesNecklace",
name = "Swap Games Necklace",
description = "",
position = 37,
group = "Jewellery swapper"
)
default boolean getGamesNecklace()
{
return false;
}
@ConfigItem(
keyName = "gamesNecklaceMode",
name = "Mode",
description = "",
position = 38,
group = "Jewellery swapper",
hidden = true,
unhide = "swapGamesNecklace"
)
default GamesNecklaceMode getGamesNecklaceMode()
{
return GamesNecklaceMode.BURTHORPE;
}
@ConfigItem(
keyName = "swapDuelingRing",
name = "Swap Dueling Ring",
description = "",
position = 39,
group = "Jewellery swapper"
)
default boolean getDuelingRing()
{
return false;
}
@ConfigItem(
keyName = "duelingRingMode",
name = "Mode",
description = "",
position = 40,
group = "Jewellery swapper",
hidden = true,
unhide = "swapDuelingRing"
)
default DuelingRingMode getDuelingRingMode()
{
return DuelingRingMode.DUEL_ARENA;
}
@ConfigItem(
keyName = "swapGlory",
name = "Swap Glory",
description = "",
position = 41,
group = "Jewellery swapper"
)
default boolean getGlory()
{
return false;
}
@ConfigItem(
keyName = "gloryMode",
name = "Mode",
description = "",
position = 42,
group = "Jewellery swapper",
hidden = true,
unhide = "swapGlory"
)
default GloryMode getGloryMode()
{
return GloryMode.EDGEVILLE;
}
@ConfigItem(
keyName = "swapSkill",
name = "Swap Skill",
description = "",
position = 43,
group = "Jewellery swapper"
)
default boolean getSkillsNecklace()
{
return false;
}
@ConfigItem(
keyName = "skillsnecklacemode",
name = "Mode",
description = "",
position = 44,
group = "Jewellery swapper",
hidden = true,
unhide = "swapSkill"
)
default SkillsNecklaceMode getSkillsNecklaceMode()
{
return SkillsNecklaceMode.FARMING_GUILD;
}
@ConfigItem(
keyName = "swapPassage",
name = "Swap Passage",
description = "",
position = 45,
group = "Jewellery swapper"
)
default boolean getNecklaceofPassage()
{
return false;
}
@ConfigItem(
keyName = "necklaceofpassagemode",
name = "Mode",
description = "",
position = 46,
group = "Jewellery swapper",
hidden = true,
unhide = "swapPassage"
)
default NecklaceOfPassageMode getNecklaceofPassageMode()
{
return NecklaceOfPassageMode.WIZARDS_TOWER;
}
@ConfigItem(
keyName = "swapDigsite",
name = "Swap Digsite",
description = "",
position = 47,
group = "Jewellery swapper"
)
default boolean getDigsitePendant()
{
return false;
}
@ConfigItem(
keyName = "digsitependantmode",
name = "Mode",
description = "",
position = 48,
group = "Jewellery swapper",
hidden = true,
unhide = "swapDigsite"
)
default DigsitePendantMode getDigsitePendantMode()
{
return DigsitePendantMode.FOSSIL_ISLAND;
}
@ConfigItem(
keyName = "swapCombat",
name = "Swap Combat",
description = "",
position = 49,
group = "Jewellery swapper"
)
default boolean getCombatBracelet()
{
return false;
}
@ConfigItem(
keyName = "combatbraceletmode",
name = "Mode",
description = "",
position = 50,
group = "Jewellery swapper",
hidden = true,
unhide = "swapCombat"
)
default CombatBraceletMode getCombatBraceletMode()
{
return CombatBraceletMode.WARRIORS_GUILD;
}
@ConfigItem(
keyName = "swapslayer",
name = "Swap slayer",
description = "",
position = 51,
group = "Jewellery swapper"
)
default boolean getSlayerRing()
{
return false;
}
@ConfigItem(
keyName = "slayerringmode",
name = "Mode",
description = "",
position = 52,
group = "Jewellery swapper",
hidden = true,
unhide = "swapslayer"
)
default SlayerRingMode getSlayerRingMode()
{
return SlayerRingMode.CHECK;
}
@ConfigItem(
keyName = "swapburning",
name = "Swap burning",
description = "",
position = 53,
group = "Jewellery swapper"
)
default boolean getBurningAmulet()
{
return false;
}
@ConfigItem(
keyName = "burningamuletmode",
name = "Mode",
description = "",
position = 54,
group = "Jewellery swapper",
hidden = true,
unhide = "swapburning"
)
default BurningAmuletMode getBurningAmuletMode()
{
return BurningAmuletMode.BANDIT_CAMP;
}
@ConfigItem(
keyName = "swapxeric",
name = "Swap xeric",
description = "",
position = 55,
group = "Jewellery swapper"
)
default boolean getXericsTalisman()
{
return false;
}
@ConfigItem(
keyName = "xericstalismanmode",
name = "Mode",
description = "",
position = 56,
group = "Jewellery swapper",
hidden = true,
unhide = "swapxeric"
)
default XericsTalismanMode getXericsTalismanMode()
{
return XericsTalismanMode.XERICS_LOOKOUT;
}
@ConfigItem(
keyName = "swapwealth",
name = "Swap wealth",
description = "",
position = 57,
group = "Jewellery swapper"
)
default boolean getRingofWealth()
{
return false;
}
@ConfigItem(
keyName = "ringofwealthmode",
name = "Mode",
description = "",
position = 58,
group = "Jewellery swapper",
hidden = true,
unhide = "swapwealth"
)
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",
description = "Enables swapping of teleport and wear.",
position = 59,
group = "Equipment swapper"
)
default boolean getSwapArdougneCape()
{
return false;
}
@ConfigItem(
keyName = "swapConstructionCape",
name = "Swap Construction Cape",
description = "Enables swapping of teleport and wear.",
position = 60,
group = "Equipment swapper"
)
default boolean getSwapConstructionCape()
{
return true;
}
@ConfigItem(
keyName = "swapCraftingCape",
name = "Swap Crafting Cape",
description = "Enables swapping of teleport and wear.",
position = 61,
group = "Equipment swapper"
)
default boolean getSwapCraftingCape()
{
return true;
}
@ConfigItem(
keyName = "swapMagicCape",
name = "Swap Magic Cape",
description = "Enables swapping of spellbook and wear.",
position = 62,
group = "Equipment swapper"
)
default boolean getSwapMagicCape()
{
return true;
}
@ConfigItem(
keyName = "swapExplorersRing",
name = "Swap Explorers Ring",
description = "Enables swapping of spellbook and wear.",
position = 63,
group = "Equipment swapper"
)
default boolean getSwapExplorersRing()
{
return true;
}
}

View File

@@ -1,549 +0,0 @@
/*
* Copyright (c) 2018, Alan Baumgartner <https://github.com/alanbaumgartner>
* Copyright (c) 2018, https://runelitepl.us
* Copyright (c) 2018, Kyle <https://github.com/kyleeld>
* Copyright (c) 2018, Owain van Brakel <https://github.com/Owain94>
* 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;
import com.google.common.base.Strings;
import com.google.inject.Provides;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import net.runelite.api.Client;
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 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.GameStateChanged;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.VarbitChanged;
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;
import static net.runelite.client.util.MenuUtil.swap;
import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor(
name = "Easyscape",
type = PluginType.UTILITY
)
public class EasyscapePlugin extends Plugin
{
private static final int PURO_PURO_REGION_ID = 10307;
private MenuEntry[] entries;
private final Set<Integer> leftClickConstructionIDs = new HashSet<>();
private boolean buildingMode;
@Inject
private Client client;
@Inject
private EasyscapeConfig config;
@Inject
private MenuManager menuManager;
@Provides
EasyscapeConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(EasyscapeConfig.class);
}
@Override
public void startUp()
{
addSwaps();
loadConstructionIDs(config.getConstructionItems());
}
@Override
public void shutDown()
{
removeSwaps();
loadConstructionIDs("");
}
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (client.getGameState() != GameState.LOGGED_IN)
{
return;
}
loadConstructionIDs(config.getConstructionItems());
}
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
buildingMode = client.getVar(BUILDING_MODE) == 1;
}
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
if (client.getGameState() != GameState.LOGGED_IN)
{
return;
}
final String option = Text.standardize(event.getOption());
final String target = Text.standardize(event.getTarget());
entries = client.getMenuEntries();
if (option.contains("withdraw") || option.contains("deposit"))
{
if (config.getWithdrawOne())
{
for (String item : Text.fromCSV(config.getWithdrawOneItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-1", option, target);
swap(client, "Deposit-1", option, target);
}
}
}
if (config.getWithdrawFive())
{
for (String item : Text.fromCSV(config.getWithdrawFiveItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-5", option, target);
swap(client, "Deposit-5", option, target);
}
}
}
if (config.getWithdrawTen())
{
for (String item : Text.fromCSV(config.getWithdrawTenItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-10", option, target);
swap(client, "Deposit-10", option, target);
}
}
}
if (config.getWithdrawX())
{
for (String item : Text.fromCSV(config.getWithdrawXItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-" + config.getWithdrawXAmount(), option, target);
swap(client, "Deposit-" + config.getWithdrawXAmount(), option, target);
}
}
}
if (config.getWithdrawAll())
{
for (String item : Text.fromCSV(config.getWithdrawAllItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-All", option, target);
swap(client, "Deposit-All", option, target);
}
}
}
}
if (option.contains("buy"))
{
if (config.getSwapBuyOne() && !config.getBuyOneItems().equals(""))
{
for (String item : Text.fromCSV(config.getBuyOneItems()))
{
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);
}
}
}
}
else if (option.contains("sell"))
{
if (config.getSwapSellOne() && !config.getSellOneItems().equals(""))
{
for (String item : Text.fromCSV(config.getSellOneItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Sell 1", option, target);
}
}
}
if (config.getSwapSellFive() && !Strings.isNullOrEmpty(config.getSellFiveItems()))
{
for (String item : Text.fromCSV(config.getSellFiveItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Sell 5", option, target);
}
}
}
if (config.getSwapSellTen() && !Strings.isNullOrEmpty(config.getSellTenItems()))
{
for (String item : Text.fromCSV(config.getSellTenItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Sell 10", option, target);
}
}
}
if (config.getSwapSellFifty() && !Strings.isNullOrEmpty(config.getSellFiftyItems()))
{
for (String item : Text.fromCSV(config.getSellFiftyItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Sell 50", option, target);
}
}
}
}
if (config.getRemoveObjects() && !config.getRemovedObjects().equals(""))
{
for (String removed : Text.fromCSV(config.getRemovedObjects()))
{
removed = Text.standardize(removed);
if (target.contains("(") && target.split(" \\(")[0].equals(removed))
{
delete(event.getIdentifier());
}
else if (target.contains("->"))
{
String trimmed = target.split("->")[1].trim();
if (trimmed.length() >= removed.length() && trimmed.substring(0, removed.length()).equalsIgnoreCase(removed))
{
delete(event.getIdentifier());
break;
}
}
else if (target.length() >= removed.length() && target.substring(0, removed.length()).equalsIgnoreCase(removed))
{
delete(event.getIdentifier());
break;
}
}
}
if (config.getSwapPuro() && isPuroPuro())
{
if (event.getType() == WALK.getId())
{
MenuEntry menuEntry = entries[entries.length - 1];
menuEntry.setType(MenuAction.WALK.getId() + MENU_ACTION_DEPRIORITIZE_OFFSET);
}
else if (option.equalsIgnoreCase("examine"))
{
swap(client, "push-through", option, target);
}
else if (option.equalsIgnoreCase("use"))
{
swap(client, "escape", option, target);
}
}
else if (config.getSwapSmithing() && option.contains("smith"))
{
if (option.equalsIgnoreCase("Smith 1"))
{
swap(client, "Smith All", option, target);
}
else if (option.equalsIgnoreCase("Smith 1 Set"))
{
swap(client, "Smith All Sets", option, target);
}
}
else if (config.getSwapTanning() && option.equalsIgnoreCase("Tan 1"))
{
swap(client, "Tan All", option, target);
}
else if (config.getSwapSawmill() && target.equalsIgnoreCase("Sawmill operator"))
{
swap(client, "Buy-plank", option, target);
}
else if (config.getSwapSawmillPlanks() && option.equalsIgnoreCase("Buy 1"))
{
swap(client, "Buy All", option, target);
}
else if (option.equalsIgnoreCase("Clear-All") && target.equalsIgnoreCase("Bank Filler"))
{
swap(client, "Clear", option, target);
}
else if (target.contains("ardougne cloak") && config.getSwapArdougneCape())
{
swap(client, "Kandarin Monastery", option, target);
swap(client, "Monastery Teleport", option, target);
}
else if (target.contains("crafting cape") && config.getSwapCraftingCape())
{
swap(client, "Teleport", option, target);
}
else if (target.contains("construct. cape") && config.getSwapConstructionCape())
{
swap(client, "Tele to poh", option, target);
}
else if (target.contains("magic cape") && config.getSwapMagicCape())
{
swap(client, "Spellbook", option, target);
}
else if (target.contains("explorer's ring") && config.getSwapExplorersRing())
{
swap(client, "Teleport", option, target);
}
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (!"easyscape".equals(event.getGroup()))
{
return;
}
loadConstructionIDs(config.getConstructionItems());
removeSwaps();
addSwaps();
}
private void addSwaps()
{
if (config.getBurningAmulet())
{
menuManager.addSwap("remove", "burning amulet", config.getBurningAmuletMode().toString());
}
if (config.getCombatBracelet())
{
menuManager.addSwap("remove", "combat bracelet", config.getCombatBraceletMode().toString());
}
if (config.getGamesNecklace())
{
menuManager.addSwap("remove", "games necklace", config.getGamesNecklaceMode().toString());
}
if (config.getDuelingRing())
{
menuManager.addSwap("remove", "ring of dueling", config.getDuelingRingMode().toString());
}
if (config.getGlory())
{
menuManager.addSwap("remove", "amulet of glory", config.getGloryMode().toString());
menuManager.addSwap("remove", "amulet of eternal glory", config.getGloryMode().toString());
}
if (config.getSkillsNecklace())
{
menuManager.addSwap("remove", "skills necklace", config.getSkillsNecklaceMode().toString());
}
if (config.getNecklaceofPassage())
{
menuManager.addSwap("remove", "necklace of passage", config.getNecklaceofPassageMode().toString());
}
if (config.getDigsitePendant())
{
menuManager.addSwap("remove", "digsite pendant", config.getDigsitePendantMode().toString());
}
if (config.getSlayerRing())
{
menuManager.addSwap("remove", "slayer ring", config.getSlayerRingMode().toString());
}
if (config.getXericsTalisman())
{
menuManager.addSwap("remove", "xeric's talisman", config.getXericsTalismanMode().toString());
}
if (config.getRingofWealth())
{
menuManager.addSwap("remove", "ring of wealth", config.getRingofWealthMode().toString());
}
if (config.swapMax())
{
menuManager.addSwap("remove", "max cape", config.maxMode().toString());
}
}
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)
{
for (int i = entries.length - 1; i >= 0; i--)
{
if (entries[i].getIdentifier() == target)
{
entries = ArrayUtils.remove(entries, i);
i--;
}
}
client.setMenuEntries(entries);
}
private boolean isPuroPuro()
{
Player player = client.getLocalPlayer();
if (player == null)
{
return false;
}
else
{
WorldPoint location = player.getWorldLocation();
return location.getRegionID() == PURO_PURO_REGION_ID;
}
}
private void loadConstructionIDs(String from)
{
if (client.getGameState() != GameState.LOGGED_IN
|| Strings.isNullOrEmpty(from) && leftClickConstructionIDs.isEmpty())
{
return;
}
if (!leftClickConstructionIDs.isEmpty())
{
for (int i : leftClickConstructionIDs)
{
menuManager.toggleLeftClick("build", i, true);
menuManager.toggleLeftClick("remove", i, true);
}
leftClickConstructionIDs.clear();
}
if (config.getEasyConstruction() &&
!Strings.isNullOrEmpty(from) &&
buildingMode)
{
for (String s : Text.fromCSV(from))
{
int id = Integer.parseInt(s.replaceAll("[^0-9]", ""));
if (leftClickConstructionIDs.contains(id))
{
continue;
}
if (menuManager.toggleLeftClick("build", id, false)
|| menuManager.toggleLeftClick("remove", id, false))
{
leftClickConstructionIDs.add(id);
}
}
}
}
}

View File

@@ -1,6 +1,8 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Kamiel
* Copyright (c) 2018, Kyle <https://github.com/kyleeld>
* Copyright (c) 2018, lucouswin <https://github.com/lucouswin>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,29 +28,39 @@
package net.runelite.client.plugins.menuentryswapper;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import joptsimple.internal.Strings;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.ItemComposition;
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 net.runelite.api.NPC;
import net.runelite.api.Player;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOpened;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.PostItemComposition;
import net.runelite.api.events.WidgetMenuOptionClicked;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.widgets.WidgetInfo;
import static net.runelite.api.Varbits.BUILDING_MODE;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
@@ -58,17 +70,24 @@ import net.runelite.client.input.KeyManager;
import net.runelite.client.menus.ComparableEntry;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.menus.WidgetMenuOption;
import net.runelite.client.plugins.menuentryswapper.util.FairyRingMode;
import net.runelite.client.plugins.menuentryswapper.util.HouseMode;
import net.runelite.client.plugins.menuentryswapper.util.ObeliskMode;
import net.runelite.client.plugins.menuentryswapper.util.OccultAltarMode;
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;
import net.runelite.client.util.MiscUtils;
import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor(
name = "Menu Entry Swapper",
description = "Change the default option that is displayed when hovering over objects",
tags = {"npcs", "inventory", "items", "objects"},
enabledByDefault = false
name = "Menu Entry Swapper",
description = "Change the default option that is displayed when hovering over objects",
tags = {"npcs", "inventory", "items", "objects"},
type = PluginType.UTILITY,
enabledByDefault = false
)
public class MenuEntrySwapperPlugin extends Plugin
{
@@ -78,37 +97,42 @@ public class MenuEntrySwapperPlugin extends Plugin
private static final String MENU_TARGET = "Shift-click";
private static final String CONFIG_GROUP = "shiftclick";
private static final String ITEM_KEY_PREFIX = "item_";
private static final int PURO_PURO_REGION_ID = 10307;
private MenuEntry[] entries;
private final Set<Integer> leftClickConstructionIDs = new HashSet<>();
private boolean buildingMode;
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
private static final WidgetMenuOption FIXED_INVENTORY_TAB_SAVE = new WidgetMenuOption(SAVE,
MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB);
private static final WidgetMenuOption RESIZABLE_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
private static final WidgetMenuOption RESIZABLE_INVENTORY_TAB_SAVE = new WidgetMenuOption(SAVE,
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB);
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE = new WidgetMenuOption(SAVE,
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB);
private static final Set<MenuAction> NPC_MENU_TYPES = ImmutableSet.of(
MenuAction.NPC_FIRST_OPTION,
MenuAction.NPC_SECOND_OPTION,
MenuAction.NPC_THIRD_OPTION,
MenuAction.NPC_FOURTH_OPTION,
MenuAction.NPC_FIFTH_OPTION,
MenuAction.EXAMINE_NPC);
MenuAction.NPC_FIRST_OPTION,
MenuAction.NPC_SECOND_OPTION,
MenuAction.NPC_THIRD_OPTION,
MenuAction.NPC_FOURTH_OPTION,
MenuAction.NPC_FIFTH_OPTION,
MenuAction.EXAMINE_NPC);
private static final Splitter NEWLINE_SPLITTER = Splitter
.on("\n")
.omitEmptyStrings()
.trimResults();
.on("\n")
.omitEmptyStrings()
.trimResults();
private final Map<ComparableEntry, ComparableEntry> customSwaps = new HashMap<>();
@@ -151,6 +175,9 @@ public class MenuEntrySwapperPlugin extends Plugin
@Override
public void startUp()
{
addSwaps();
loadConstructionIDs(config.getConstructionItems());
if (config.shiftClickCustomization())
{
enableCustomization();
@@ -163,13 +190,23 @@ public class MenuEntrySwapperPlugin extends Plugin
public void shutDown()
{
disableCustomization();
loadConstructionIDs("");
loadCustomSwaps(""); // Removes all custom swaps
removeSwaps();
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (!"menuentryswapper".equals(event.getGroup()))
{
return;
}
loadConstructionIDs(config.getConstructionItems());
removeSwaps();
addSwaps();
if (!CONFIG_GROUP.equals(event.getGroup()))
{
if (event.getKey().equals("customSwaps"))
@@ -246,17 +283,111 @@ public class MenuEntrySwapperPlugin extends Plugin
public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event)
{
if (event.getWidget() == WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB)
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB)
{
configuringShiftClick = event.getMenuOption().equals(CONFIGURE) && Text.removeTags(event.getMenuTarget()).equals(MENU_TARGET);
refreshShiftClickCustomizationMenus();
}
}
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (client.getGameState() != GameState.LOGGED_IN)
{
return;
}
loadConstructionIDs(config.getConstructionItems());
}
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
buildingMode = client.getVar(BUILDING_MODE) == 1;
}
@Subscribe
public void onMenuOpened(MenuOpened event)
{
Player localPlayer = client.getLocalPlayer();
if (localPlayer == null)
{
return;
}
if (!(MiscUtils.getWildernessLevelFrom(client, localPlayer.getWorldLocation()) >= 0))
{
return;
}
List<MenuEntry> menu_entries = new ArrayList<>();
for (MenuEntry entry : event.getMenuEntries())
{
String option = Text.removeTags(entry.getOption()).toLowerCase();
if (option.contains("trade with") && config.hideTradeWith())
{
continue;
}
if (option.contains("lookup") && config.hideLookup())
{
continue;
}
if (option.contains("report") && config.hideReport())
{
continue;
}
if (option.contains("examine") && config.hideExamine())
{
continue;
}
if (option.contains("net") && config.hideNet())
{
continue;
}
if (option.contains("bait") && config.hideBait())
{
continue;
}
int identifier = entry.getIdentifier();
Player[] players = client.getCachedPlayers();
Player player = null;
if (identifier >= 0 && identifier < players.length)
{
player = players[identifier];
}
if (player == null)
{
menu_entries.add(entry);
continue;
}
if ((option.contains("attack") || option.contains("cast")) && (player.isFriend() || player.isClanMember()))
{
continue;
}
menu_entries.add(entry);
}
MenuEntry[] updated_menu_entries = new MenuEntry[menu_entries.size()];
updated_menu_entries = menu_entries.toArray(updated_menu_entries);
client.setMenuEntries(updated_menu_entries);
if (!configuringShiftClick)
{
return;
@@ -381,13 +512,271 @@ public class MenuEntrySwapperPlugin extends Plugin
}
final int eventId = event.getIdentifier();
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());
final NPC hintArrowNpc = client.getHintArrowNpc();
entries = client.getMenuEntries();
if (option.contains("withdraw") || option.contains("deposit"))
{
if (config.getWithdrawOne())
{
for (String item : Text.fromCSV(config.getWithdrawOneItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-1", option, target);
swap(client, "Deposit-1", option, target);
}
}
}
if (config.getWithdrawFive())
{
for (String item : Text.fromCSV(config.getWithdrawFiveItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-5", option, target);
swap(client, "Deposit-5", option, target);
}
}
}
if (config.getWithdrawTen())
{
for (String item : Text.fromCSV(config.getWithdrawTenItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-10", option, target);
swap(client, "Deposit-10", option, target);
}
}
}
if (config.getWithdrawX())
{
for (String item : Text.fromCSV(config.getWithdrawXItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-" + config.getWithdrawXAmount(), option, target);
swap(client, "Deposit-" + config.getWithdrawXAmount(), option, target);
}
}
}
if (config.getWithdrawAll())
{
for (String item : Text.fromCSV(config.getWithdrawAllItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Withdraw-All", option, target);
swap(client, "Deposit-All", option, target);
}
}
}
}
if (option.contains("buy"))
{
if (config.getSwapBuyOne() && !config.getBuyOneItems().equals(""))
{
for (String item : Text.fromCSV(config.getBuyOneItems()))
{
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);
}
}
}
}
else if (option.contains("sell"))
{
if (config.getSwapSellOne() && !config.getSellOneItems().equals(""))
{
for (String item : Text.fromCSV(config.getSellOneItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Sell 1", option, target);
}
}
}
if (config.getSwapSellFive() && !Strings.isNullOrEmpty(config.getSellFiveItems()))
{
for (String item : Text.fromCSV(config.getSellFiveItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Sell 5", option, target);
}
}
}
if (config.getSwapSellTen() && !Strings.isNullOrEmpty(config.getSellTenItems()))
{
for (String item : Text.fromCSV(config.getSellTenItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Sell 10", option, target);
}
}
}
if (config.getSwapSellFifty() && !Strings.isNullOrEmpty(config.getSellFiftyItems()))
{
for (String item : Text.fromCSV(config.getSellFiftyItems()))
{
if (target.equals(Text.standardize(item)))
{
swap(client, "Sell 50", option, target);
}
}
}
}
if (config.getRemoveObjects() && !config.getRemovedObjects().equals(""))
{
for (String removed : Text.fromCSV(config.getRemovedObjects()))
{
removed = Text.standardize(removed);
if (target.contains("(") && target.split(" \\(")[0].equals(removed))
{
delete(event.getIdentifier());
}
else if (target.contains("->"))
{
String trimmed = target.split("->")[1].trim();
if (trimmed.length() >= removed.length() && trimmed.substring(0, removed.length()).equalsIgnoreCase(removed))
{
delete(event.getIdentifier());
break;
}
}
else if (target.length() >= removed.length() && target.substring(0, removed.length()).equalsIgnoreCase(removed))
{
delete(event.getIdentifier());
break;
}
}
}
if (config.getSwapPuro() && isPuroPuro())
{
if (event.getType() == WALK.getId())
{
MenuEntry menuEntry = entries[entries.length - 1];
menuEntry.setType(MenuAction.WALK.getId() + MENU_ACTION_DEPRIORITIZE_OFFSET);
}
else if (option.equalsIgnoreCase("examine"))
{
swap(client, "push-through", option, target);
}
else if (option.equalsIgnoreCase("use"))
{
swap(client, "escape", option, target);
}
}
else if (config.getSwapSmithing() && option.contains("smith"))
{
if (option.equalsIgnoreCase("Smith 1"))
{
swap(client, "Smith All", option, target);
}
else if (option.equalsIgnoreCase("Smith 1 Set"))
{
swap(client, "Smith All Sets", option, target);
}
}
else if (config.getSwapTanning() && option.equalsIgnoreCase("Tan 1"))
{
swap(client, "Tan All", option, target);
}
else if (config.getSwapSawmill() && target.equalsIgnoreCase("Sawmill operator"))
{
swap(client, "Buy-plank", option, target);
}
else if (config.getSwapSawmillPlanks() && option.equalsIgnoreCase("Buy 1"))
{
swap(client, "Buy All", option, target);
}
else if (option.equalsIgnoreCase("Clear-All") && target.equalsIgnoreCase("Bank Filler"))
{
swap(client, "Clear", option, target);
}
else if (target.contains("ardougne cloak") && config.getSwapArdougneCape())
{
swap(client, "Kandarin Monastery", option, target);
swap(client, "Monastery Teleport", option, target);
}
else if (target.contains("crafting cape") && config.getSwapCraftingCape())
{
swap(client, "Teleport", option, target);
}
else if (target.contains("construct. cape") && config.getSwapConstructionCape())
{
swap(client, "Tele to poh", option, target);
}
else if (target.contains("magic cape") && config.getSwapMagicCape())
{
swap(client, "Spellbook", option, target);
}
else if (target.contains("explorer's ring") && config.getSwapExplorersRing())
{
swap(client, "Teleport", option, target);
}
if (hintArrowNpc != null
&& hintArrowNpc.getIndex() == eventId
&& NPC_MENU_TYPES.contains(MenuAction.of(event.getType())))
&& hintArrowNpc.getIndex() == eventId
&& NPC_MENU_TYPES.contains(MenuAction.of(event.getType())))
{
return;
}
@@ -433,7 +822,7 @@ public class MenuEntrySwapperPlugin extends Plugin
{
swap(client, "assignment", option, target, true);
}
if (config.swapPlank())
{
swap(client, "buy-plank", option, target, true);
@@ -449,7 +838,7 @@ public class MenuEntrySwapperPlugin extends Plugin
{
swap(client, "claim-slime", option, target, true);
}
if (config.claimDynamite() && target.contains("Thirus"))
{
swap(client, "claim-dynamite", option, target, true);
@@ -489,7 +878,7 @@ public class MenuEntrySwapperPlugin extends Plugin
{
swap(client, "quick-travel", option, target, true);
}
if (config.swapStory())
{
swap(client, "story", option, target, true);
@@ -505,7 +894,7 @@ public class MenuEntrySwapperPlugin extends Plugin
{
swap(client, "edgeville", option, target, true);
}
else if (config.swapMetamorphosis() && target.contains("baby chinchompa"))
{
swap(client, "metamorphosis", option, target, true);
@@ -515,7 +904,7 @@ public class MenuEntrySwapperPlugin extends Plugin
{
swap(client, "stun", option, target, true);
}
else if (config.swapTravel() && option.equals("pass") && target.equals("energy barrier"))
{
swap(client, "pay-toll(2-ecto)", option, target, true);
@@ -541,44 +930,44 @@ public class MenuEntrySwapperPlugin extends Plugin
swap(client, "harpoon", option, target, true);
}
else if (config.swapOccult() != OccultAltarMode.VENERATE && option.equals("venerate"))
else if (config.swapOccultMode() != OccultAltarMode.VENERATE && option.equals("venerate"))
{
switch (config.swapOccult())
switch (config.swapOccultMode())
{
case VENERATE:
swap(client, "Venerate", option, target, true);
break;
break;
case ANCIENT:
swap(client, "Ancient", option, target, true);
break;
break;
case LUNAR:
swap(client, "Lunar", option, target, true);
break;
swap(client, "Lunar", option, target, true);
break;
case ARCEUUS:
swap(client, "Arceuus", option, target, true);
swap(client, "Arceuus", option, target, true);
}
}
else if (config.swapObelisk() != ObeliskMode.ACTIVATE && option.equals("activate"))
else if (config.swapObeliskMode() != ObeliskMode.ACTIVATE && option.equals("activate"))
{
switch (config.swapObelisk())
switch (config.swapObeliskMode())
{
case ACTIVATE:
swap(client, "activate", option, target, true);
break;
break;
case SET_DESTINATION:
swap(client, "set destination", option, target, true);
break;
break;
case TELEPORT_TO_DESTINATION:
swap(client, "teleport to destination", option, target, true);
break;
break;
}
}
else if (config.swapHomePortal() != HouseMode.ENTER && option.equals("enter"))
else if (config.swapHomePortalMode() != HouseMode.ENTER && option.equals("enter"))
{
switch (config.swapHomePortal())
switch (config.swapHomePortalMode())
{
case HOME:
swap(client, "home", option, target, true);
@@ -591,20 +980,20 @@ else if (config.swapOccult() != OccultAltarMode.VENERATE && option.equals("vener
break;
}
}
else if (config.swapFairyRing() != FairyRingMode.OFF && config.swapFairyRing() != FairyRingMode.ZANARIS
&& (option.equals("zanaris") || option.equals("configure") || option.equals("tree")))
else if (config.swapFairyRingMode() != FairyRingMode.OFF && config.swapFairyRingMode() != FairyRingMode.ZANARIS
&& (option.equals("zanaris") || option.equals("configure") || option.equals("tree")))
{
if (config.swapFairyRing() == FairyRingMode.LAST_DESTINATION)
if (config.swapFairyRingMode() == FairyRingMode.LAST_DESTINATION)
{
swap(client, "last-destination", option, target, false);
}
else if (config.swapFairyRing() == FairyRingMode.CONFIGURE)
else if (config.swapFairyRingMode() == FairyRingMode.CONFIGURE)
{
swap(client, "configure", option, target, false);
}
}
else if (config.swapFairyRing() == FairyRingMode.ZANARIS && option.equals("tree"))
else if (config.swapFairyRingMode() == FairyRingMode.ZANARIS && option.equals("tree"))
{
swap(client, "zanaris", option, target, false);
}
@@ -667,7 +1056,7 @@ else if (config.swapOccult() != OccultAltarMode.VENERATE && option.equals("vener
{
swap(client, "search", option, target, true);
}
else if (config.swapRogueschests() && target.contains("chest"))
{
swap(client, "search for traps", option, target, true);
@@ -822,6 +1211,155 @@ else if (config.swapOccult() != OccultAltarMode.VENERATE && option.equals("vener
}
}
private void addSwaps()
{
if (config.getBurningAmulet())
{
menuManager.addSwap("remove", "burning amulet", config.getBurningAmuletMode().toString());
}
if (config.getCombatBracelet())
{
menuManager.addSwap("remove", "combat bracelet", config.getCombatBraceletMode().toString());
}
if (config.getGamesNecklace())
{
menuManager.addSwap("remove", "games necklace", config.getGamesNecklaceMode().toString());
}
if (config.getDuelingRing())
{
menuManager.addSwap("remove", "ring of dueling", config.getDuelingRingMode().toString());
}
if (config.getGlory())
{
menuManager.addSwap("remove", "amulet of glory", config.getGloryMode().toString());
menuManager.addSwap("remove", "amulet of eternal glory", config.getGloryMode().toString());
}
if (config.getSkillsNecklace())
{
menuManager.addSwap("remove", "skills necklace", config.getSkillsNecklaceMode().toString());
}
if (config.getNecklaceofPassage())
{
menuManager.addSwap("remove", "necklace of passage", config.getNecklaceofPassageMode().toString());
}
if (config.getDigsitePendant())
{
menuManager.addSwap("remove", "digsite pendant", config.getDigsitePendantMode().toString());
}
if (config.getSlayerRing())
{
menuManager.addSwap("remove", "slayer ring", config.getSlayerRingMode().toString());
}
if (config.getXericsTalisman())
{
menuManager.addSwap("remove", "xeric's talisman", config.getXericsTalismanMode().toString());
}
if (config.getRingofWealth())
{
menuManager.addSwap("remove", "ring of wealth", config.getRingofWealthMode().toString());
}
if (config.swapMax())
{
menuManager.addSwap("remove", "max cape", config.maxMode().toString());
}
}
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)
{
for (int i = entries.length - 1; i >= 0; i--)
{
if (entries[i].getIdentifier() == target)
{
entries = ArrayUtils.remove(entries, i);
i--;
}
}
client.setMenuEntries(entries);
}
private boolean isPuroPuro()
{
Player player = client.getLocalPlayer();
if (player == null)
{
return false;
}
else
{
WorldPoint location = player.getWorldLocation();
return location.getRegionID() == PURO_PURO_REGION_ID;
}
}
private void loadConstructionIDs(String from)
{
if (client.getGameState() != GameState.LOGGED_IN
|| Strings.isNullOrEmpty(from) && leftClickConstructionIDs.isEmpty())
{
return;
}
if (!leftClickConstructionIDs.isEmpty())
{
for (int i : leftClickConstructionIDs)
{
menuManager.toggleLeftClick("build", i, true);
menuManager.toggleLeftClick("remove", i, true);
}
leftClickConstructionIDs.clear();
}
if (config.getEasyConstruction() &&
!Strings.isNullOrEmpty(from) &&
buildingMode)
{
for (String s : Text.fromCSV(from))
{
int id = Integer.parseInt(s.replaceAll("[^0-9]", ""));
if (leftClickConstructionIDs.contains(id))
{
continue;
}
if (menuManager.toggleLeftClick("build", id, false)
|| menuManager.toggleLeftClick("remove", id, false))
{
leftClickConstructionIDs.add(id);
}
}
}
}
void startShift()
{
if (!config.swapClimbUpDown())

View File

@@ -23,7 +23,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum BurningAmuletMode
{

View File

@@ -23,7 +23,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum CombatBraceletMode
{

View File

@@ -23,7 +23,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum DigsitePendantMode
{

View File

@@ -22,7 +22,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum DuelingRingMode
{

View File

@@ -22,7 +22,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

View File

@@ -22,7 +22,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum GamesNecklaceMode
{
@@ -30,7 +30,7 @@ public enum GamesNecklaceMode
BARBARIAN_OUTPOST("Barbarian Outpost"),
CORPOREAL_BEAST("Corporeal Beast"),
TEARS_OF_GUTHIX("Tears of Guthix"),
WINTERTODT("Wintertodt Camp");
WINTER("Wintertodt Camp");
private final String name;

View File

@@ -22,7 +22,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum GloryMode
{

View File

@@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.menuentryswapper;
package net.runelite.client.plugins.menuentryswapper.util;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

View File

@@ -1,4 +1,4 @@
package net.runelite.client.plugins.easyscape.util;
package net.runelite.client.plugins.menuentryswapper.util;
public enum MaxCapeMode
{

View File

@@ -23,13 +23,13 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum NecklaceOfPassageMode
{
WIZARDS_TOWER("Wizard's Tower"),
WIZARDS_TOWER("Wizards' Tower"),
THE_OUTPOST("The Outpost"),
EAGLES_EYRIE("Eagle's Eyrie");
EAGLES_EYRIE("Eagles' Eyrie");
private final String name;

View File

@@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.menuentryswapper;
package net.runelite.client.plugins.menuentryswapper.util;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

View File

@@ -22,7 +22,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

View File

@@ -23,7 +23,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum RingOfWealthMode
{

View File

@@ -23,7 +23,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum SkillsNecklaceMode
{

View File

@@ -23,7 +23,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum SlayerRingMode
{

View File

@@ -23,7 +23,7 @@
* (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;
package net.runelite.client.plugins.menuentryswapper.util;
public enum XericsTalismanMode
{

View File

@@ -1,99 +0,0 @@
/*
* Copyright (c) 2018, https://runelitepl.us
* 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.menumodifier;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("menumodifier")
public interface MenuModifierConfig extends Config
{
@ConfigItem(
position = 0,
keyName = "hideExamine",
name = "Hide Examine",
description = "Hides the 'examine' option from the right click menu"
)
default boolean hideExamine()
{
return true;
}
@ConfigItem(
position = 1,
keyName = "hideTradeWith",
name = "Hide Trade With",
description = "Hides the 'trade with' option from the right click menu"
)
default boolean hideTradeWith()
{
return true;
}
@ConfigItem(
position = 2,
keyName = "hideReport",
name = "Hide Report",
description = "Hides the 'report' option from the right click menu"
)
default boolean hideReport()
{
return true;
}
@ConfigItem(
position = 3,
keyName = "hideLookup",
name = "Hide Lookup",
description = "Hides the 'lookup' option from the right click menu"
)
default boolean hideLookup()
{
return true;
}
@ConfigItem(
position = 4,
keyName = "hideNet",
name = "Hide Net",
description = "Hides the 'net' option from the right click menu"
)
default boolean hideNet()
{
return true;
}
@ConfigItem(
position = 5,
keyName = "hideBait",
name = "Hide Bait",
description = "Hides the 'Bait' option from the right click menu"
)
default boolean hideBait()
{
return true;
}
}

View File

@@ -1,62 +0,0 @@
/*
* Copyright (c) 2018, https://runelitepl.us
* 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.menumodifier;
import java.awt.event.KeyEvent;
import javax.inject.Inject;
import net.runelite.client.input.KeyListener;
import net.runelite.client.input.MouseAdapter;
public class MenuModifierInputListener extends MouseAdapter implements KeyListener
{
private static final int HOTKEY = KeyEvent.VK_CONTROL;
@Override
public void keyTyped(KeyEvent e)
{
}
@Inject
private MenuModifierPlugin plugin;
@Override
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() == HOTKEY)
{
plugin.setHotKeyPressed(true);
}
}
@Override
public void keyReleased(KeyEvent e)
{
if (e.getKeyCode() == HOTKEY)
{
plugin.setHotKeyPressed(false);
}
}
}

View File

@@ -1,217 +0,0 @@
/*
* Copyright (c) 2018, https://runelitepl.us
* 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.menumodifier;
import com.google.inject.Provides;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.Client;
import net.runelite.api.MenuEntry;
import net.runelite.api.Player;
import net.runelite.api.events.MenuOpened;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.util.MiscUtils;
import net.runelite.client.util.Text;
@PluginDescriptor(
name = "Menu Modifier",
description = "Changes right click menu for players",
tags = {"menu", "modifier", "right", "click", "pk", "bogla"},
enabledByDefault = false,
type = PluginType.UTILITY
)
public class MenuModifierPlugin extends Plugin
{
@Inject
private Client client;
@Inject
private MenuModifierConfig config;
@Inject
private MenuModifierInputListener inputListener;
@Inject
private KeyManager keyManager;
@Provides
MenuModifierConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(MenuModifierConfig.class);
}
@Override
protected void startUp() throws Exception
{
keyManager.registerKeyListener(inputListener);
}
@Override
protected void shutDown() throws Exception
{
keyManager.unregisterKeyListener(inputListener);
}
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private boolean hotKeyPressed;
@Subscribe
public void onMenuOpened(MenuOpened event)
{
Player localPlayer = client.getLocalPlayer();
if (localPlayer == null)
{
return;
}
if (!(MiscUtils.getWildernessLevelFrom(client, localPlayer.getWorldLocation()) >= 0))
{
return;
}
if (hotKeyPressed)
{
return;
}
List<MenuEntry> menu_entries = new ArrayList<>();
for (MenuEntry entry : event.getMenuEntries())
{
String option = Text.removeTags(entry.getOption()).toLowerCase();
if (option.contains("trade with") && config.hideTradeWith())
{
continue;
}
if (option.contains("lookup") && config.hideLookup())
{
continue;
}
if (option.contains("report") && config.hideReport())
{
continue;
}
if (option.contains("examine") && config.hideExamine())
{
continue;
}
if (option.contains("net") && config.hideNet())
{
continue;
}
if (option.contains("bait") && config.hideBait())
{
continue;
}
int identifier = entry.getIdentifier();
Player[] players = client.getCachedPlayers();
Player player = null;
if (identifier >= 0 && identifier < players.length)
{
player = players[identifier];
}
if (player == null)
{
menu_entries.add(entry);
continue;
}
if ((option.contains("attack") || option.contains("cast")) && (player.isFriend() || player.isClanMember()))
{
continue;
}
menu_entries.add(entry);
}
MenuEntry[] updated_menu_entries = new MenuEntry[menu_entries.size()];
updated_menu_entries = menu_entries.toArray(updated_menu_entries);
client.setMenuEntries(updated_menu_entries);
}
/*@Subscribe
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
{
if (true)
return;
if (!inWilderness)
return;
if (hotKeyPressed)
return;
String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase();
if ((option.contains("trade with") && config.hideTradeWith())
|| (option.contains("lookup") && config.hideLookup())
|| (option.contains("report") && config.hideReport())
|| (option.contains("examine") && config.hideExamine())
|| (option.contains("cancel") && config.hideCancel()))
{
int identifier = menuEntryAdded.getIdentifier();
Player[] players = client.getCachedPlayers();
Player player = null;
if (identifier >= 0 && identifier < players.length)
player = players[identifier];
if (player == null)
return;
//allow trading with friends/clanmates
if (option.contains("trade with") && (player.isFriend() || player.isClanMember()))
return;
MenuEntry[] menuEntries = client.getMenuEntries();
if (menuEntries.length > 0)
client.setMenuEntries(Arrays.copyOf(menuEntries, menuEntries.length - 1));
}
}*/
}