From ef6ea5b18f955b50e12b12cf526fd111940f1568 Mon Sep 17 00:00:00 2001 From: se7enAte9 <50936458+se7enAte9@users.noreply.github.com> Date: Mon, 15 Jul 2019 03:30:24 -0400 Subject: [PATCH] pvptools: fix attack/cast hidden options (#986) * pvptools: fix attack/cast options * menuentryswapper: fix tob/cox hide cast options * menuentryswapper: fix hide cast options in raids * menuentryswapper: add plugin dependency * pvptools: add pvp world/wilderness check * menuentryswapper: fix hiding cast when enabling config setting * menuentryswapper: fix checkstyle --- .../main/java/net/runelite/api/Client.java | 14 +- .../MenuEntrySwapperConfig.java | 50 +++- .../MenuEntrySwapperPlugin.java | 124 +++++++-- .../plugins/pvptools/PvpToolsConfig.java | 51 +++- .../plugins/pvptools/PvpToolsPlugin.java | 261 +++++++++++++----- .../net/runelite/mixins/RSClientMixin.java | 27 +- 6 files changed, 424 insertions(+), 103 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 3eaadba176..1caa667aa9 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -1679,15 +1679,25 @@ public interface Client extends GameShell boolean isSpellSelected(); /** - * Set whether or not player attack options will be hidden for clanmembers/friends + * Set whether or not player attack options will be hidden for friends */ void setHideFriendAttackOptions(boolean yes); /** - * Set whether or not player cast options will be hidden for clanmembers/friends + * Set whether or not player cast options will be hidden for friends */ void setHideFriendCastOptions(boolean yes); + /** + * Set whether or not player attack options will be hidden for clanmates + */ + void setHideClanmateAttackOptions(boolean yes); + + /** + * Set whether or not player cast options will be hidden for clanmates + */ + void setHideClanmateCastOptions(boolean yes); + /** * Set spells excluded from above hiding */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index 642d93b028..06850797da 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -1669,28 +1669,56 @@ default CharterOption charterOption() //------------------------------------------------------------// @ConfigItem( - keyName = "removeFreezePlayerToB", - name = "Remove freeze in ToB", - description = "Removes the freeze option for ice barrage, ice blitz, entangle etc. in ToB", + keyName = "hideCastToB", + name = "Hide cast in ToB", + description = "Hides the cast option for clanmates and friends in ToB", position = 0, group = "PVM" ) - default boolean getRemoveFreezePlayerToB() + default boolean hideCastToB() { return true; } @ConfigItem( - keyName = "removeFreezePlayerCoX", - name = "Remove freeze in CoX", - description = "Removes the freeze option for ice barrage, ice blitz, entangle etc. in CoX", + keyName = "hideCastIgnoredToB", + name = "Ignored spells", + description = "Spells that should not be hidden from being cast, separated by a comma", position = 1, + group = "PVM", + hidden = true, + unhide = "hideCastToB" + ) + default String hideCastIgnoredToB() + { + return "cure other, energy transfer, heal other, vengeance other"; + } + + @ConfigItem( + keyName = "hideCastCoX", + name = "Hide cast in CoX", + description = "Hides the cast option for clanmates and friends in CoX", + position = 2, group = "PVM" ) - default boolean getRemoveFreezePlayerCoX() - { - return true; - } + default boolean hideCastCoX() + { + return true; + } + + @ConfigItem( + keyName = "hideCastIgnoredCoX", + name = "Ignored spells", + description = "Spells that should not be hidden from being cast, separated by a comma", + position = 3, + group = "PVM", + hidden = true, + unhide = "hideCastCoX" + ) + default String hideCastIgnoredCoX() + { + return "cure other, energy transfer, heal other, vengeance other"; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index fb3565a5d8..4d0a41b109 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -31,6 +31,7 @@ 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.common.collect.Sets; import com.google.inject.Provides; import java.util.ArrayList; import java.util.Arrays; @@ -58,6 +59,8 @@ import net.runelite.api.NPC; import net.runelite.api.Player; import net.runelite.api.Varbits; import static net.runelite.api.Varbits.BUILDING_MODE; + +import net.runelite.api.WorldType; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; @@ -79,7 +82,9 @@ import net.runelite.client.menus.ComparableEntry; import net.runelite.client.menus.MenuManager; import net.runelite.client.menus.WidgetMenuOption; import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDependency; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.PluginManager; import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.menuentryswapper.util.BurningAmuletMode; import net.runelite.client.plugins.menuentryswapper.util.CombatBraceletMode; @@ -101,6 +106,9 @@ import net.runelite.client.plugins.menuentryswapper.util.SlayerRingMode; import net.runelite.client.plugins.menuentryswapper.util.XericsTalismanMode; import net.runelite.client.plugins.menuentryswapper.util.teleEquippedMode; import static net.runelite.client.util.MenuUtil.swap; + +import net.runelite.client.plugins.pvptools.PvpToolsConfig; +import net.runelite.client.plugins.pvptools.PvpToolsPlugin; import net.runelite.client.util.MiscUtils; import net.runelite.client.util.Text; import org.apache.commons.lang3.ArrayUtils; @@ -113,6 +121,7 @@ import org.apache.commons.lang3.ArrayUtils; enabledByDefault = false ) @Singleton +@PluginDependency(PvpToolsPlugin.class) public class MenuEntrySwapperPlugin extends Plugin { private static final String CONFIGURE = "Configure"; @@ -128,6 +137,8 @@ public class MenuEntrySwapperPlugin extends Plugin private MenuEntry[] entries; private final Set leftClickConstructionItems = new HashSet<>(); private boolean buildingMode; + private boolean inTobRaid = false; + private boolean inCoxRaid = false; private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE, MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB); @@ -177,6 +188,9 @@ public class MenuEntrySwapperPlugin extends Plugin @Inject private ConfigManager configManager; + @Inject + private PluginManager pluginManager; + @Inject private KeyManager keyManager; @@ -186,6 +200,12 @@ public class MenuEntrySwapperPlugin extends Plugin @Inject private ItemManager itemManager; + @Inject + private PvpToolsPlugin pvpTools; + + @Inject + private PvpToolsConfig pvpToolsConfig; + @Getter(AccessLevel.PACKAGE) private boolean configuringShiftClick = false; @@ -313,8 +333,10 @@ public class MenuEntrySwapperPlugin extends Plugin private boolean hideDestroyBoltpouch; private boolean hideDestroyGembag; private boolean hideDropRunecraftingPouch; - private boolean getRemoveFreezePlayerToB; - private boolean getRemoveFreezePlayerCoX; + private boolean hideCastToB; + private Set hideCastIgnoredToB; + private boolean hideCastCoX; + private Set hideCastIgnoredCoX; @Provides MenuEntrySwapperConfig provideConfig(ConfigManager configManager) @@ -328,8 +350,6 @@ public class MenuEntrySwapperPlugin extends Plugin updateConfig(); addSwaps(); loadConstructionItems(config.getEasyConstructionItems()); - client.setHideFriendCastOptions(config.getRemoveFreezePlayerToB()); - client.setHideFriendCastOptions(config.getRemoveFreezePlayerCoX()); if (config.shiftClickCustomization()) { @@ -337,16 +357,25 @@ public class MenuEntrySwapperPlugin extends Plugin } loadCustomSwaps(config.customSwaps()); + + if (client.getGameState() == GameState.LOGGED_IN) + { + setCastOptions(true); + } } @Override public void shutDown() { - client.setHideFriendCastOptions(false); disableCustomization(); loadConstructionItems(""); loadCustomSwaps(""); // Removes all custom swaps removeSwaps(); + + if (client.getGameState() == GameState.LOGGED_IN) + { + resetCastOptions(); + } } @Subscribe @@ -356,7 +385,7 @@ public class MenuEntrySwapperPlugin extends Plugin { return; } - + updateConfig(); loadConstructionItems(this.getEasyConstructionItems); @@ -369,8 +398,6 @@ public class MenuEntrySwapperPlugin extends Plugin { loadCustomSwaps(this.configCustomSwaps); } - - return; } if (event.getKey().equals("shiftClickCustomization")) @@ -389,19 +416,27 @@ public class MenuEntrySwapperPlugin extends Plugin clientThread.invoke(this::resetItemDefinitionCache); } - if (event.getKey().equals("removeFreezePlayerToB")) + else if ((event.getKey().equals("hideCastToB") || event.getKey().equals("hideCastIgnoredToB"))) { - if (this.getRemoveFreezePlayerToB && client.getVar(Varbits.THEATRE_OF_BLOOD) == 2) + if (this.hideCastToB) { - client.setHideFriendCastOptions(config.getRemoveFreezePlayerToB()); + setCastOptions(true); + } + else + { + resetCastOptions(); } } - if (event.getKey().equals("removeFreezePlayerCoX")) + else if ((event.getKey().equals("hideCastCoX") || event.getKey().equals("hideCastIgnoredCoX"))) { - if (this.getRemoveFreezePlayerCoX && client.getVar(Varbits.IN_RAID) == 1) + if (this.hideCastCoX) { - client.setHideFriendCastOptions(config.getRemoveFreezePlayerCoX()); + setCastOptions(true); + } + else + { + resetCastOptions(); } } } @@ -478,6 +513,8 @@ public class MenuEntrySwapperPlugin extends Plugin public void onVarbitChanged(VarbitChanged event) { buildingMode = client.getVar(BUILDING_MODE) == 1; + + setCastOptions(false); } @Subscribe @@ -1699,6 +1736,59 @@ public class MenuEntrySwapperPlugin extends Plugin menuManager.removePriorityEntry("climb-down"); } + private void setCastOptions(boolean force) + { + clientThread.invoke(() -> + { + boolean tmpInCoxRaid = client.getVar(Varbits.IN_RAID) == 1; + if (tmpInCoxRaid != inCoxRaid || force) + { + if (tmpInCoxRaid && this.hideCastCoX) + { + client.setHideFriendCastOptions(true); + client.setHideClanmateCastOptions(true); + client.setUnhiddenCasts(this.hideCastIgnoredCoX); + } + + inCoxRaid = tmpInCoxRaid; + } + + boolean tmpInTobRaid = client.getVar(Varbits.THEATRE_OF_BLOOD) == 2; + if (tmpInTobRaid != inTobRaid || force) + { + if (tmpInTobRaid && this.hideCastToB) + { + client.setHideFriendCastOptions(true); + client.setHideClanmateCastOptions(true); + client.setUnhiddenCasts(this.hideCastIgnoredToB); + } + + inTobRaid = tmpInTobRaid; + } + + if (!inCoxRaid && !inTobRaid) + { + resetCastOptions(); + } + }); + } + + private void resetCastOptions() + { + clientThread.invoke(() -> + { + if (client.getVar(Varbits.IN_WILDERNESS) == 1 || WorldType.isAllPvpWorld(client.getWorldType()) && pluginManager.isPluginEnabled(pvpTools) && pvpToolsConfig.hideCast()) + { + pvpTools.setCastOptions(); + } + else + { + client.setHideFriendCastOptions(false); + client.setHideClanmateCastOptions(false); + } + }); + } + private void updateConfig() { this.getWithdrawOne = config.getWithdrawOne(); @@ -1822,7 +1912,9 @@ public class MenuEntrySwapperPlugin extends Plugin this.hideDestroyBoltpouch = config.hideDestroyBoltpouch(); this.hideDestroyGembag = config.hideDestroyGembag(); this.hideDropRunecraftingPouch = config.hideDropRunecraftingPouch(); - this.getRemoveFreezePlayerToB = config.getRemoveFreezePlayerToB(); - this.getRemoveFreezePlayerCoX = config.getRemoveFreezePlayerCoX(); + this.hideCastToB = config.hideCastToB(); + this.hideCastIgnoredToB = Sets.newHashSet(Text.fromCSV(config.hideCastIgnoredToB().toLowerCase())); + this.hideCastCoX = config.hideCastCoX(); + this.hideCastIgnoredCoX = Sets.newHashSet(Text.fromCSV(config.hideCastIgnoredCoX().toLowerCase())); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java index bd0b9e17e3..bd1fbe4319 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java @@ -76,31 +76,68 @@ public interface PvpToolsConfig extends Config keyName = "hideAttack", name = "Hide attack", description = "Hides the attack option for clanmates, friends, or both", - position = 5, - group = "Right-Click Attack Options" + position = 5 ) default boolean hideAttack() { return false; } + @ConfigItem( + keyName = "hideAttackMode", + name = "Mode", + description = "", + position = 6, + hidden = true, + unhide = "hideAttack" + ) + default AttackMode hideAttackMode() + { + return AttackMode.FRIENDS; + } + @ConfigItem( keyName = "hideCast", name = "Hide cast", description = "Hides the cast option for clanmates, friends, or both", - position = 7, - group = "Right-Click Attack Options" + position = 7 ) default boolean hideCast() { return false; } + @ConfigItem( + keyName = "hideCastMode", + name = "Mode", + description = "", + position = 8, + hidden = true, + unhide = "hideCast" + ) + default AttackMode hideCastMode() + { + return AttackMode.FRIENDS; + } + + @ConfigItem( + keyName = "hideCastIgnored", + name = "Ignored spells", + description = "Spells that should not be hidden from being cast, separated by a comma", + position = 9, + hidden = true, + unhide = "hideCast" + ) + default String hideCastIgnored() + { + return "cure other, energy transfer, heal other, vengeance other"; + } + @ConfigItem( keyName = "riskCalculator", name = "Risk Calculator", description = "Enables a panel in the PvP Tools Panel that shows the players current risk", - position = 13 + position = 10 ) default boolean riskCalculatorEnabled() { @@ -111,7 +148,7 @@ public interface PvpToolsConfig extends Config keyName = "missingPlayers", name = "Missing CC Players", description = "Adds a button to the PvP Tools panel that opens a window showing which CC members are not at the current players location", - position = 14 + position = 11 ) default boolean missingPlayersEnabled() { @@ -122,7 +159,7 @@ public interface PvpToolsConfig extends Config keyName = "currentPlayers", name = "Current CC Players", description = "Adds a button to the PvP Tools panel that opens a window showing which CC members currently at the players location", - position = 15 + position = 12 ) default boolean currentPlayersEnabled() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java index b0b7d100f4..62dbf46bb9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java @@ -11,6 +11,7 @@ package net.runelite.client.plugins.pvptools; +import com.google.common.collect.Sets; import com.google.inject.Provides; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -20,6 +21,7 @@ import java.util.Comparator; import java.util.List; import java.util.NavigableMap; import java.util.Objects; +import java.util.Set; import java.util.TreeMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; @@ -36,11 +38,14 @@ import net.runelite.api.Item; import net.runelite.api.ItemDefinition; import net.runelite.api.Player; import net.runelite.api.SkullIcon; +import net.runelite.api.Varbits; +import net.runelite.api.WorldType; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.PlayerDespawned; import net.runelite.api.events.PlayerSpawned; +import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.config.Keybind; import net.runelite.client.eventbus.Subscribe; @@ -87,6 +92,7 @@ public class PvpToolsPlugin extends Plugin @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) private boolean hideAll; + private boolean loaded; @Inject private OverlayManager overlayManager; @@ -94,6 +100,9 @@ public class PvpToolsPlugin extends Plugin @Inject private Client client; + @Inject + private ClientThread clientThread; + @Inject private ItemManager itemManager; @@ -149,7 +158,10 @@ public class PvpToolsPlugin extends Plugin private boolean missingPlayersEnabled; private boolean currentPlayersEnabled; private boolean hideAttack; + private AttackMode hideAttackMode; private boolean hideCast; + private AttackMode hideCastMode; + private Set unhiddenCasts; @Inject private ClientToolbar clientToolbar; @@ -238,8 +250,6 @@ public class PvpToolsPlugin extends Plugin overlayManager.add(pvpToolsOverlay); overlayManager.add(playerCountOverlay); - client.setHideFriendAttackOptions(this.hideAttack); - client.setHideFriendCastOptions(this.hideCast); keyManager.registerKeyListener(fallinHotkeyListener); keyManager.registerKeyListener(renderselfHotkeyListener); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "skull.png"); @@ -258,7 +268,6 @@ public class PvpToolsPlugin extends Plugin panel.currentPlayers.addActionListener(currentPlayersActionListener); clientToolbar.addNavigation(navButton); - if (this.missingPlayersEnabled) { panel.missingPlayers.setVisible(true); @@ -269,6 +278,10 @@ public class PvpToolsPlugin extends Plugin panel.currentPlayers.setVisible(true); } + if (client.getGameState() == GameState.LOGGED_IN) + { + setCastOptions(); + } } @Override @@ -279,8 +292,13 @@ public class PvpToolsPlugin extends Plugin keyManager.unregisterKeyListener(fallinHotkeyListener); keyManager.unregisterKeyListener(renderselfHotkeyListener); clientToolbar.removeNavigation(navButton); - client.setHideFriendAttackOptions(false); - client.setHideFriendCastOptions(false); + + if (client.getGameState() == GameState.LOGGED_IN) + { + resetCastOptions(); + } + + loaded = false; } @Subscribe @@ -290,60 +308,72 @@ public class PvpToolsPlugin extends Plugin { return; } - client.setHideFriendAttackOptions(this.hideAttack); - client.setHideFriendCastOptions(this.hideCast); - if (configChanged.getGroup().equals("pvptools")) + updateConfig(); + + switch (configChanged.getKey()) { - updateConfig(); - - switch (configChanged.getKey()) - { - case "countPlayers": - if (this.countPlayers) - { - updatePlayers(); - } - if (!this.countPlayers) - { - panel.disablePlayerCount(); - } - break; - case "countOverHeads": - if (this.countOverHeads) - { - countOverHeads(); - } - if (!this.countOverHeads) - { - panel.disablePrayerCount(); - } - break; - case "riskCalculator": - if (this.riskCalculatorEnabled) - { - getCarriedWealth(); - } - if (!this.riskCalculatorEnabled) - { - panel.disableRiskCalculator(); - } - break; - case "missingPlayers": - if (this.missingPlayersEnabled) - { - panel.missingPlayers.setVisible(true); - } - break; - case "currentPlayers": - if (this.currentPlayersEnabled) - { - panel.currentPlayers.setVisible(true); - } - break; - default: - break; - } + case "countPlayers": + if (this.countPlayers) + { + updatePlayers(); + } + if (!this.countPlayers) + { + panel.disablePlayerCount(); + } + break; + case "countOverHeads": + if (this.countOverHeads) + { + countOverHeads(); + } + if (!this.countOverHeads) + { + panel.disablePrayerCount(); + } + break; + case "riskCalculator": + if (this.riskCalculatorEnabled) + { + getCarriedWealth(); + } + if (!this.riskCalculatorEnabled) + { + panel.disableRiskCalculator(); + } + break; + case "missingPlayers": + if (this.missingPlayersEnabled) + { + panel.missingPlayers.setVisible(true); + } + break; + case "currentPlayers": + if (this.currentPlayersEnabled) + { + panel.currentPlayers.setVisible(true); + } + break; + case "hideAttack": + case "hideAttackMode": + if (this.hideAttack) + { + hideAttackOptions(this.hideAttackMode); + } + else + { + client.setHideFriendAttackOptions(false); + client.setHideClanmateAttackOptions(false); + } + break; + case "hideCast": + case "hideCastMode": + case "hideCastIgnored": + setCastOptions(); + break; + default: + break; } } @@ -360,13 +390,20 @@ public class PvpToolsPlugin extends Plugin @Subscribe public void onGameStateChanged(GameStateChanged event) { - if (event.getGameState().equals(GameState.LOGGED_IN) && this.riskCalculatorEnabled) + if (event.getGameState().equals(GameState.LOGGED_IN)) { - getCarriedWealth(); - } - if (event.getGameState().equals(GameState.LOGGED_IN) && this.countPlayers) - { - updatePlayers(); + if (this.riskCalculatorEnabled) + { + getCarriedWealth(); + } + if (this.countPlayers) + { + updatePlayers(); + } + if (!loaded) + { + setCastOptions(); + } } } @@ -577,6 +614,101 @@ public class PvpToolsPlugin extends Plugin panel.biggestItemLabel.repaint(); } + /** + * Given an AttackMode, hides the appropriate attack options. + * @param mode The {@link AttackMode} specifying clanmates, friends, or both. + */ + public void hideAttackOptions(AttackMode mode) + { + switch (mode) + { + case CLAN: + client.setHideClanmateAttackOptions(true); + client.setHideFriendAttackOptions(false); + break; + case FRIENDS: + client.setHideFriendAttackOptions(true); + client.setHideClanmateAttackOptions(false); + break; + case BOTH: + client.setHideClanmateAttackOptions(true); + client.setHideFriendAttackOptions(true); + break; + } + } + + /** + * Given an AttackMode, hides the appropriate cast options. + * @param mode The {@link AttackMode} specifying clanmates, friends, or both. + */ + public void hideCastOptions(AttackMode mode) + { + switch (mode) + { + case CLAN: + client.setHideClanmateCastOptions(true); + client.setHideFriendCastOptions(false); + break; + case FRIENDS: + client.setHideFriendCastOptions(true); + client.setHideClanmateCastOptions(false); + break; + case BOTH: + client.setHideClanmateCastOptions(true); + client.setHideFriendCastOptions(true); + break; + } + } + + public void setCastOptions() + { + clientThread.invoke(() -> + { + if ((client.getVar(Varbits.IN_RAID) == 1 || client.getVar(Varbits.THEATRE_OF_BLOOD) == 2) + || (client.getVar(Varbits.IN_WILDERNESS) != 1 && !WorldType.isAllPvpWorld(client.getWorldType()))) + { + return; + } + + if (this.hideAttack) + { + hideAttackOptions(this.hideAttackMode); + } + else + { + client.setHideFriendAttackOptions(false); + client.setHideClanmateAttackOptions(false); + } + + if (this.hideCast) + { + hideCastOptions(this.hideCastMode); + } + else + { + client.setHideFriendCastOptions(false); + client.setHideClanmateCastOptions(false); + } + + client.setUnhiddenCasts(this.unhiddenCasts); + + loaded = true; + }); + } + + private void resetCastOptions() + { + clientThread.invoke(() -> + { + if (client.getVar(Varbits.IN_RAID) == 1 || client.getVar(Varbits.THEATRE_OF_BLOOD) == 2) + { + return; + } + + client.setHideFriendAttackOptions(false); + client.setHideFriendCastOptions(false); + }); + } private void updateConfig() { @@ -589,6 +721,9 @@ public class PvpToolsPlugin extends Plugin this.missingPlayersEnabled = config.missingPlayersEnabled(); this.currentPlayersEnabled = config.currentPlayersEnabled(); this.hideAttack = config.hideAttack(); + this.hideAttackMode = config.hideAttackMode(); this.hideCast = config.hideCast(); + this.hideCastMode = config.hideCastMode(); + this.unhiddenCasts = Sets.newHashSet(Text.fromCSV(config.hideCastIgnored().toLowerCase())); } } \ No newline at end of file diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index cca4cae90d..7ebba2349d 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -208,9 +208,15 @@ public abstract class RSClientMixin implements RSClient @Inject private static boolean hideFriendAttackOptions = false; + @Inject + private static boolean hideClanmateAttackOptions = false; + @Inject private static boolean hideFriendCastOptions = false; + @Inject + private static boolean hideClanmateCastOptions = false; + @Inject private static Set unhiddenCasts = new HashSet(); @@ -228,6 +234,20 @@ public abstract class RSClientMixin implements RSClient hideFriendCastOptions = yes; } + @Inject + @Override + public void setHideClanmateAttackOptions(boolean yes) + { + hideClanmateAttackOptions = yes; + } + + @Inject + @Override + public void setHideClanmateCastOptions(boolean yes) + { + hideClanmateCastOptions = yes; + } + @Inject @Override public void setUnhiddenCasts(Set casts) @@ -1644,12 +1664,11 @@ public abstract class RSClientMixin implements RSClient { if (client.isSpellSelected()) { - return hideFriendCastOptions - && (p.isFriended() || p.isClanMember()) - && !unhiddenCasts.contains(client.getSelectedSpellName()); + return ((hideFriendCastOptions && p.isFriended()) || (hideClanmateCastOptions && p.isClanMember())) + && !unhiddenCasts.contains(client.getSelectedSpellName().replaceAll("<[^>]*>", "").toLowerCase()); } - return hideFriendAttackOptions && (p.isFriended() || p.isClanMember()); + return ((hideFriendAttackOptions && p.isFriended()) || (hideClanmateAttackOptions && p.isClanMember())); } @Inject