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
This commit is contained in:
se7enAte9
2019-07-15 03:30:24 -04:00
committed by Kyleeld
parent b53c3bb1f7
commit ef6ea5b18f
6 changed files with 424 additions and 103 deletions

View File

@@ -1679,15 +1679,25 @@ public interface Client extends GameShell
boolean isSpellSelected(); 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); 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); 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 * Set spells excluded from above hiding
*/ */

View File

@@ -1669,28 +1669,56 @@ default CharterOption charterOption()
//------------------------------------------------------------// //------------------------------------------------------------//
@ConfigItem( @ConfigItem(
keyName = "removeFreezePlayerToB", keyName = "hideCastToB",
name = "Remove freeze in ToB", name = "Hide cast in ToB",
description = "Removes the freeze option for ice barrage, ice blitz, entangle etc. in ToB", description = "Hides the cast option for clanmates and friends in ToB",
position = 0, position = 0,
group = "PVM" group = "PVM"
) )
default boolean getRemoveFreezePlayerToB() default boolean hideCastToB()
{ {
return true; return true;
} }
@ConfigItem( @ConfigItem(
keyName = "removeFreezePlayerCoX", keyName = "hideCastIgnoredToB",
name = "Remove freeze in CoX", name = "Ignored spells",
description = "Removes the freeze option for ice barrage, ice blitz, entangle etc. in CoX", description = "Spells that should not be hidden from being cast, separated by a comma",
position = 1, 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" group = "PVM"
) )
default boolean getRemoveFreezePlayerCoX() default boolean hideCastCoX()
{ {
return true; 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";
}
} }

View File

@@ -31,6 +31,7 @@ package net.runelite.client.plugins.menuentryswapper;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -58,6 +59,8 @@ import net.runelite.api.NPC;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import static net.runelite.api.Varbits.BUILDING_MODE; import static net.runelite.api.Varbits.BUILDING_MODE;
import net.runelite.api.WorldType;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged; 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.MenuManager;
import net.runelite.client.menus.WidgetMenuOption; import net.runelite.client.menus.WidgetMenuOption;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginManager;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.menuentryswapper.util.BurningAmuletMode; import net.runelite.client.plugins.menuentryswapper.util.BurningAmuletMode;
import net.runelite.client.plugins.menuentryswapper.util.CombatBraceletMode; 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.XericsTalismanMode;
import net.runelite.client.plugins.menuentryswapper.util.teleEquippedMode; import net.runelite.client.plugins.menuentryswapper.util.teleEquippedMode;
import static net.runelite.client.util.MenuUtil.swap; 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.MiscUtils;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@@ -113,6 +121,7 @@ import org.apache.commons.lang3.ArrayUtils;
enabledByDefault = false enabledByDefault = false
) )
@Singleton @Singleton
@PluginDependency(PvpToolsPlugin.class)
public class MenuEntrySwapperPlugin extends Plugin public class MenuEntrySwapperPlugin extends Plugin
{ {
private static final String CONFIGURE = "Configure"; private static final String CONFIGURE = "Configure";
@@ -128,6 +137,8 @@ public class MenuEntrySwapperPlugin extends Plugin
private MenuEntry[] entries; private MenuEntry[] entries;
private final Set<String> leftClickConstructionItems = new HashSet<>(); private final Set<String> leftClickConstructionItems = new HashSet<>();
private boolean buildingMode; private boolean buildingMode;
private boolean inTobRaid = false;
private boolean inCoxRaid = false;
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE, 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);
@@ -177,6 +188,9 @@ public class MenuEntrySwapperPlugin extends Plugin
@Inject @Inject
private ConfigManager configManager; private ConfigManager configManager;
@Inject
private PluginManager pluginManager;
@Inject @Inject
private KeyManager keyManager; private KeyManager keyManager;
@@ -186,6 +200,12 @@ public class MenuEntrySwapperPlugin extends Plugin
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Inject
private PvpToolsPlugin pvpTools;
@Inject
private PvpToolsConfig pvpToolsConfig;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private boolean configuringShiftClick = false; private boolean configuringShiftClick = false;
@@ -313,8 +333,10 @@ public class MenuEntrySwapperPlugin extends Plugin
private boolean hideDestroyBoltpouch; private boolean hideDestroyBoltpouch;
private boolean hideDestroyGembag; private boolean hideDestroyGembag;
private boolean hideDropRunecraftingPouch; private boolean hideDropRunecraftingPouch;
private boolean getRemoveFreezePlayerToB; private boolean hideCastToB;
private boolean getRemoveFreezePlayerCoX; private Set<String> hideCastIgnoredToB;
private boolean hideCastCoX;
private Set<String> hideCastIgnoredCoX;
@Provides @Provides
MenuEntrySwapperConfig provideConfig(ConfigManager configManager) MenuEntrySwapperConfig provideConfig(ConfigManager configManager)
@@ -328,8 +350,6 @@ public class MenuEntrySwapperPlugin extends Plugin
updateConfig(); updateConfig();
addSwaps(); addSwaps();
loadConstructionItems(config.getEasyConstructionItems()); loadConstructionItems(config.getEasyConstructionItems());
client.setHideFriendCastOptions(config.getRemoveFreezePlayerToB());
client.setHideFriendCastOptions(config.getRemoveFreezePlayerCoX());
if (config.shiftClickCustomization()) if (config.shiftClickCustomization())
{ {
@@ -337,16 +357,25 @@ public class MenuEntrySwapperPlugin extends Plugin
} }
loadCustomSwaps(config.customSwaps()); loadCustomSwaps(config.customSwaps());
if (client.getGameState() == GameState.LOGGED_IN)
{
setCastOptions(true);
}
} }
@Override @Override
public void shutDown() public void shutDown()
{ {
client.setHideFriendCastOptions(false);
disableCustomization(); disableCustomization();
loadConstructionItems(""); loadConstructionItems("");
loadCustomSwaps(""); // Removes all custom swaps loadCustomSwaps(""); // Removes all custom swaps
removeSwaps(); removeSwaps();
if (client.getGameState() == GameState.LOGGED_IN)
{
resetCastOptions();
}
} }
@Subscribe @Subscribe
@@ -356,7 +385,7 @@ public class MenuEntrySwapperPlugin extends Plugin
{ {
return; return;
} }
updateConfig(); updateConfig();
loadConstructionItems(this.getEasyConstructionItems); loadConstructionItems(this.getEasyConstructionItems);
@@ -369,8 +398,6 @@ public class MenuEntrySwapperPlugin extends Plugin
{ {
loadCustomSwaps(this.configCustomSwaps); loadCustomSwaps(this.configCustomSwaps);
} }
return;
} }
if (event.getKey().equals("shiftClickCustomization")) if (event.getKey().equals("shiftClickCustomization"))
@@ -389,19 +416,27 @@ public class MenuEntrySwapperPlugin extends Plugin
clientThread.invoke(this::resetItemDefinitionCache); 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) public void onVarbitChanged(VarbitChanged event)
{ {
buildingMode = client.getVar(BUILDING_MODE) == 1; buildingMode = client.getVar(BUILDING_MODE) == 1;
setCastOptions(false);
} }
@Subscribe @Subscribe
@@ -1699,6 +1736,59 @@ public class MenuEntrySwapperPlugin extends Plugin
menuManager.removePriorityEntry("climb-down"); 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() private void updateConfig()
{ {
this.getWithdrawOne = config.getWithdrawOne(); this.getWithdrawOne = config.getWithdrawOne();
@@ -1822,7 +1912,9 @@ public class MenuEntrySwapperPlugin extends Plugin
this.hideDestroyBoltpouch = config.hideDestroyBoltpouch(); this.hideDestroyBoltpouch = config.hideDestroyBoltpouch();
this.hideDestroyGembag = config.hideDestroyGembag(); this.hideDestroyGembag = config.hideDestroyGembag();
this.hideDropRunecraftingPouch = config.hideDropRunecraftingPouch(); this.hideDropRunecraftingPouch = config.hideDropRunecraftingPouch();
this.getRemoveFreezePlayerToB = config.getRemoveFreezePlayerToB(); this.hideCastToB = config.hideCastToB();
this.getRemoveFreezePlayerCoX = config.getRemoveFreezePlayerCoX(); this.hideCastIgnoredToB = Sets.newHashSet(Text.fromCSV(config.hideCastIgnoredToB().toLowerCase()));
this.hideCastCoX = config.hideCastCoX();
this.hideCastIgnoredCoX = Sets.newHashSet(Text.fromCSV(config.hideCastIgnoredCoX().toLowerCase()));
} }
} }

View File

@@ -76,31 +76,68 @@ public interface PvpToolsConfig extends Config
keyName = "hideAttack", keyName = "hideAttack",
name = "Hide attack", name = "Hide attack",
description = "Hides the attack option for clanmates, friends, or both", description = "Hides the attack option for clanmates, friends, or both",
position = 5, position = 5
group = "Right-Click Attack Options"
) )
default boolean hideAttack() default boolean hideAttack()
{ {
return false; return false;
} }
@ConfigItem(
keyName = "hideAttackMode",
name = "Mode",
description = "",
position = 6,
hidden = true,
unhide = "hideAttack"
)
default AttackMode hideAttackMode()
{
return AttackMode.FRIENDS;
}
@ConfigItem( @ConfigItem(
keyName = "hideCast", keyName = "hideCast",
name = "Hide cast", name = "Hide cast",
description = "Hides the cast option for clanmates, friends, or both", description = "Hides the cast option for clanmates, friends, or both",
position = 7, position = 7
group = "Right-Click Attack Options"
) )
default boolean hideCast() default boolean hideCast()
{ {
return false; 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( @ConfigItem(
keyName = "riskCalculator", keyName = "riskCalculator",
name = "Risk Calculator", name = "Risk Calculator",
description = "Enables a panel in the PvP Tools Panel that shows the players current risk", description = "Enables a panel in the PvP Tools Panel that shows the players current risk",
position = 13 position = 10
) )
default boolean riskCalculatorEnabled() default boolean riskCalculatorEnabled()
{ {
@@ -111,7 +148,7 @@ public interface PvpToolsConfig extends Config
keyName = "missingPlayers", keyName = "missingPlayers",
name = "Missing CC Players", 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", 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() default boolean missingPlayersEnabled()
{ {
@@ -122,7 +159,7 @@ public interface PvpToolsConfig extends Config
keyName = "currentPlayers", keyName = "currentPlayers",
name = "Current CC Players", 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", 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() default boolean currentPlayersEnabled()
{ {

View File

@@ -11,6 +11,7 @@
package net.runelite.client.plugins.pvptools; package net.runelite.client.plugins.pvptools;
import com.google.common.collect.Sets;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@@ -20,6 +21,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.NavigableMap; import java.util.NavigableMap;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -36,11 +38,14 @@ import net.runelite.api.Item;
import net.runelite.api.ItemDefinition; import net.runelite.api.ItemDefinition;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.SkullIcon; 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.ConfigChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.PlayerDespawned; import net.runelite.api.events.PlayerDespawned;
import net.runelite.api.events.PlayerSpawned; import net.runelite.api.events.PlayerSpawned;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.Keybind; import net.runelite.client.config.Keybind;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
@@ -87,6 +92,7 @@ public class PvpToolsPlugin extends Plugin
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
private boolean hideAll; private boolean hideAll;
private boolean loaded;
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@@ -94,6 +100,9 @@ public class PvpToolsPlugin extends Plugin
@Inject @Inject
private Client client; private Client client;
@Inject
private ClientThread clientThread;
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@@ -149,7 +158,10 @@ public class PvpToolsPlugin extends Plugin
private boolean missingPlayersEnabled; private boolean missingPlayersEnabled;
private boolean currentPlayersEnabled; private boolean currentPlayersEnabled;
private boolean hideAttack; private boolean hideAttack;
private AttackMode hideAttackMode;
private boolean hideCast; private boolean hideCast;
private AttackMode hideCastMode;
private Set<String> unhiddenCasts;
@Inject @Inject
private ClientToolbar clientToolbar; private ClientToolbar clientToolbar;
@@ -238,8 +250,6 @@ public class PvpToolsPlugin extends Plugin
overlayManager.add(pvpToolsOverlay); overlayManager.add(pvpToolsOverlay);
overlayManager.add(playerCountOverlay); overlayManager.add(playerCountOverlay);
client.setHideFriendAttackOptions(this.hideAttack);
client.setHideFriendCastOptions(this.hideCast);
keyManager.registerKeyListener(fallinHotkeyListener); keyManager.registerKeyListener(fallinHotkeyListener);
keyManager.registerKeyListener(renderselfHotkeyListener); keyManager.registerKeyListener(renderselfHotkeyListener);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "skull.png"); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "skull.png");
@@ -258,7 +268,6 @@ public class PvpToolsPlugin extends Plugin
panel.currentPlayers.addActionListener(currentPlayersActionListener); panel.currentPlayers.addActionListener(currentPlayersActionListener);
clientToolbar.addNavigation(navButton); clientToolbar.addNavigation(navButton);
if (this.missingPlayersEnabled) if (this.missingPlayersEnabled)
{ {
panel.missingPlayers.setVisible(true); panel.missingPlayers.setVisible(true);
@@ -269,6 +278,10 @@ public class PvpToolsPlugin extends Plugin
panel.currentPlayers.setVisible(true); panel.currentPlayers.setVisible(true);
} }
if (client.getGameState() == GameState.LOGGED_IN)
{
setCastOptions();
}
} }
@Override @Override
@@ -279,8 +292,13 @@ public class PvpToolsPlugin extends Plugin
keyManager.unregisterKeyListener(fallinHotkeyListener); keyManager.unregisterKeyListener(fallinHotkeyListener);
keyManager.unregisterKeyListener(renderselfHotkeyListener); keyManager.unregisterKeyListener(renderselfHotkeyListener);
clientToolbar.removeNavigation(navButton); clientToolbar.removeNavigation(navButton);
client.setHideFriendAttackOptions(false);
client.setHideFriendCastOptions(false); if (client.getGameState() == GameState.LOGGED_IN)
{
resetCastOptions();
}
loaded = false;
} }
@Subscribe @Subscribe
@@ -290,60 +308,72 @@ public class PvpToolsPlugin extends Plugin
{ {
return; return;
} }
client.setHideFriendAttackOptions(this.hideAttack);
client.setHideFriendCastOptions(this.hideCast);
if (configChanged.getGroup().equals("pvptools")) updateConfig();
switch (configChanged.getKey())
{ {
updateConfig(); case "countPlayers":
if (this.countPlayers)
switch (configChanged.getKey()) {
{ updatePlayers();
case "countPlayers": }
if (this.countPlayers) if (!this.countPlayers)
{ {
updatePlayers(); panel.disablePlayerCount();
} }
if (!this.countPlayers) break;
{ case "countOverHeads":
panel.disablePlayerCount(); if (this.countOverHeads)
} {
break; countOverHeads();
case "countOverHeads": }
if (this.countOverHeads) if (!this.countOverHeads)
{ {
countOverHeads(); panel.disablePrayerCount();
} }
if (!this.countOverHeads) break;
{ case "riskCalculator":
panel.disablePrayerCount(); if (this.riskCalculatorEnabled)
} {
break; getCarriedWealth();
case "riskCalculator": }
if (this.riskCalculatorEnabled) if (!this.riskCalculatorEnabled)
{ {
getCarriedWealth(); panel.disableRiskCalculator();
} }
if (!this.riskCalculatorEnabled) break;
{ case "missingPlayers":
panel.disableRiskCalculator(); if (this.missingPlayersEnabled)
} {
break; panel.missingPlayers.setVisible(true);
case "missingPlayers": }
if (this.missingPlayersEnabled) break;
{ case "currentPlayers":
panel.missingPlayers.setVisible(true); if (this.currentPlayersEnabled)
} {
break; panel.currentPlayers.setVisible(true);
case "currentPlayers": }
if (this.currentPlayersEnabled) break;
{ case "hideAttack":
panel.currentPlayers.setVisible(true); case "hideAttackMode":
} if (this.hideAttack)
break; {
default: hideAttackOptions(this.hideAttackMode);
break; }
} 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 @Subscribe
public void onGameStateChanged(GameStateChanged event) public void onGameStateChanged(GameStateChanged event)
{ {
if (event.getGameState().equals(GameState.LOGGED_IN) && this.riskCalculatorEnabled) if (event.getGameState().equals(GameState.LOGGED_IN))
{ {
getCarriedWealth(); if (this.riskCalculatorEnabled)
} {
if (event.getGameState().equals(GameState.LOGGED_IN) && this.countPlayers) getCarriedWealth();
{ }
updatePlayers(); if (this.countPlayers)
{
updatePlayers();
}
if (!loaded)
{
setCastOptions();
}
} }
} }
@@ -577,6 +614,101 @@ public class PvpToolsPlugin extends Plugin
panel.biggestItemLabel.repaint(); 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() private void updateConfig()
{ {
@@ -589,6 +721,9 @@ public class PvpToolsPlugin extends Plugin
this.missingPlayersEnabled = config.missingPlayersEnabled(); this.missingPlayersEnabled = config.missingPlayersEnabled();
this.currentPlayersEnabled = config.currentPlayersEnabled(); this.currentPlayersEnabled = config.currentPlayersEnabled();
this.hideAttack = config.hideAttack(); this.hideAttack = config.hideAttack();
this.hideAttackMode = config.hideAttackMode();
this.hideCast = config.hideCast(); this.hideCast = config.hideCast();
this.hideCastMode = config.hideCastMode();
this.unhiddenCasts = Sets.newHashSet(Text.fromCSV(config.hideCastIgnored().toLowerCase()));
} }
} }

View File

@@ -208,9 +208,15 @@ public abstract class RSClientMixin implements RSClient
@Inject @Inject
private static boolean hideFriendAttackOptions = false; private static boolean hideFriendAttackOptions = false;
@Inject
private static boolean hideClanmateAttackOptions = false;
@Inject @Inject
private static boolean hideFriendCastOptions = false; private static boolean hideFriendCastOptions = false;
@Inject
private static boolean hideClanmateCastOptions = false;
@Inject @Inject
private static Set<String> unhiddenCasts = new HashSet<String>(); private static Set<String> unhiddenCasts = new HashSet<String>();
@@ -228,6 +234,20 @@ public abstract class RSClientMixin implements RSClient
hideFriendCastOptions = yes; hideFriendCastOptions = yes;
} }
@Inject
@Override
public void setHideClanmateAttackOptions(boolean yes)
{
hideClanmateAttackOptions = yes;
}
@Inject
@Override
public void setHideClanmateCastOptions(boolean yes)
{
hideClanmateCastOptions = yes;
}
@Inject @Inject
@Override @Override
public void setUnhiddenCasts(Set<String> casts) public void setUnhiddenCasts(Set<String> casts)
@@ -1644,12 +1664,11 @@ public abstract class RSClientMixin implements RSClient
{ {
if (client.isSpellSelected()) if (client.isSpellSelected())
{ {
return hideFriendCastOptions return ((hideFriendCastOptions && p.isFriended()) || (hideClanmateCastOptions && p.isClanMember()))
&& (p.isFriended() || p.isClanMember()) && !unhiddenCasts.contains(client.getSelectedSpellName().replaceAll("<[^>]*>", "").toLowerCase());
&& !unhiddenCasts.contains(client.getSelectedSpellName());
} }
return hideFriendAttackOptions && (p.isFriended() || p.isClanMember()); return ((hideFriendAttackOptions && p.isFriended()) || (hideClanmateAttackOptions && p.isClanMember()));
} }
@Inject @Inject