pvptools: add config option to hide attack/cast on friends/clan from
right click menu, and fix bug causing config options to override each other.
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.pvptools;
|
||||||
|
|
||||||
|
public enum AttackMode
|
||||||
|
{
|
||||||
|
CLAN("Clan"),
|
||||||
|
FRIENDS("Friends"),
|
||||||
|
BOTH("Both");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
AttackMode(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
keyName = "countPlayers",
|
keyName = "countPlayers",
|
||||||
name = "Count Players",
|
name = "Count Players",
|
||||||
description = "When in PvP zones, counts the attackable players in and not in player's CC",
|
description = "When in PvP zones, counts the attackable players in and not in player's CC",
|
||||||
position = 3
|
position = 0
|
||||||
)
|
)
|
||||||
default boolean countPlayers()
|
default boolean countPlayers()
|
||||||
{
|
{
|
||||||
@@ -32,7 +32,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
keyName = "countOverHeads",
|
keyName = "countOverHeads",
|
||||||
name = "Count Enemy Overheads",
|
name = "Count Enemy Overheads",
|
||||||
description = "Counts the number of each protection prayer attackable targets not in your CC are currently using",
|
description = "Counts the number of each protection prayer attackable targets not in your CC are currently using",
|
||||||
position = 4
|
position = 1
|
||||||
)
|
)
|
||||||
default boolean countOverHeads()
|
default boolean countOverHeads()
|
||||||
{
|
{
|
||||||
@@ -43,7 +43,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
keyName = "fallInHelper",
|
keyName = "fallInHelper",
|
||||||
name = "Fall In Helper",
|
name = "Fall In Helper",
|
||||||
description = "Hides all non-friendly player entities other than the one that is attacking you.",
|
description = "Hides all non-friendly player entities other than the one that is attacking you.",
|
||||||
position = 5
|
position = 2
|
||||||
)
|
)
|
||||||
default boolean fallInHelper()
|
default boolean fallInHelper()
|
||||||
{
|
{
|
||||||
@@ -54,7 +54,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
keyName = "hotkey",
|
keyName = "hotkey",
|
||||||
name = "Fall In Hotkey",
|
name = "Fall In Hotkey",
|
||||||
description = "Turns the fall in helper on or off when you press this hotkey",
|
description = "Turns the fall in helper on or off when you press this hotkey",
|
||||||
position = 6
|
position = 3
|
||||||
)
|
)
|
||||||
default Keybind hotkey()
|
default Keybind hotkey()
|
||||||
{
|
{
|
||||||
@@ -65,18 +65,84 @@ public interface PvpToolsConfig extends Config
|
|||||||
keyName = "renderSelfHotkey",
|
keyName = "renderSelfHotkey",
|
||||||
name = "Render Self Hotkey",
|
name = "Render Self Hotkey",
|
||||||
description = "Toggles renderself when you press the hotkey",
|
description = "Toggles renderself when you press the hotkey",
|
||||||
position = 7
|
position = 4
|
||||||
)
|
)
|
||||||
default Keybind renderSelf()
|
default Keybind renderSelf()
|
||||||
{
|
{
|
||||||
return Keybind.NOT_SET;
|
return Keybind.NOT_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "hideAttack",
|
||||||
|
name = "Hide attack",
|
||||||
|
description = "Hides the attack option for clanmates, friends, or both",
|
||||||
|
position = 5,
|
||||||
|
group = "Right-Click Attack Options"
|
||||||
|
)
|
||||||
|
default boolean hideAttack()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "hideAttackMode",
|
||||||
|
name = "Mode",
|
||||||
|
description = "",
|
||||||
|
position = 6,
|
||||||
|
group = "Right-Click Attack Options",
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
default boolean hideCast()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "hideCastMode",
|
||||||
|
name = "Mode",
|
||||||
|
description = "",
|
||||||
|
position = 8,
|
||||||
|
group = "Right-Click Attack Options",
|
||||||
|
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,
|
||||||
|
group = "Right-Click Attack Options",
|
||||||
|
hidden = true,
|
||||||
|
unhide = "hideCast"
|
||||||
|
)
|
||||||
|
default String hideCastIgnored()
|
||||||
|
{
|
||||||
|
return "cure other, energy transfer, heal other, vengeance other";
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "attackOptionsClan",
|
keyName = "attackOptionsClan",
|
||||||
name = "Move CC Attack Option",
|
name = "Move CC Attack Option",
|
||||||
description = "Moves the attack option for people in the same CC",
|
description = "Moves the attack option for people in the same CC",
|
||||||
position = 8,
|
position = 10,
|
||||||
group = "Right-Click Attack Options"
|
group = "Right-Click Attack Options"
|
||||||
)
|
)
|
||||||
default boolean attackOptionsClan()
|
default boolean attackOptionsClan()
|
||||||
@@ -88,7 +154,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
keyName = "attackOptionsFriend",
|
keyName = "attackOptionsFriend",
|
||||||
name = "Move Friend Attack Options",
|
name = "Move Friend Attack Options",
|
||||||
description = "Moves the attack option for people on your friends list",
|
description = "Moves the attack option for people on your friends list",
|
||||||
position = 9,
|
position = 11,
|
||||||
group = "Right-Click Attack Options"
|
group = "Right-Click Attack Options"
|
||||||
)
|
)
|
||||||
default boolean attackOptionsFriend()
|
default boolean attackOptionsFriend()
|
||||||
@@ -100,7 +166,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
keyName = "levelRangeAttackOptions",
|
keyName = "levelRangeAttackOptions",
|
||||||
name = "Moves Other Attack Options",
|
name = "Moves Other Attack Options",
|
||||||
description = "Moves the attack option for people that are outside your level range",
|
description = "Moves the attack option for people that are outside your level range",
|
||||||
position = 10,
|
position = 12,
|
||||||
group = "Right-Click Attack Options"
|
group = "Right-Click Attack Options"
|
||||||
)
|
)
|
||||||
default boolean levelRangeAttackOptions()
|
default boolean levelRangeAttackOptions()
|
||||||
@@ -112,7 +178,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
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 = 14
|
position = 13
|
||||||
)
|
)
|
||||||
default boolean riskCalculatorEnabled()
|
default boolean riskCalculatorEnabled()
|
||||||
{
|
{
|
||||||
@@ -123,7 +189,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 = 15
|
position = 14
|
||||||
)
|
)
|
||||||
default boolean missingPlayersEnabled()
|
default boolean missingPlayersEnabled()
|
||||||
{
|
{
|
||||||
@@ -134,7 +200,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 = 16
|
position = 15
|
||||||
)
|
)
|
||||||
default boolean currentPlayersEnabled()
|
default boolean currentPlayersEnabled()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ 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;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -40,6 +41,7 @@ import net.runelite.api.events.FocusChanged;
|
|||||||
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.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
|
import net.runelite.api.events.MenuOpened;
|
||||||
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.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
@@ -61,6 +63,7 @@ import net.runelite.client.util.PvPUtil;
|
|||||||
import static net.runelite.client.util.StackFormatter.quantityToRSDecimalStack;
|
import static net.runelite.client.util.StackFormatter.quantityToRSDecimalStack;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "PvP Tools",
|
name = "PvP Tools",
|
||||||
@@ -179,6 +182,8 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
|
|
||||||
private int[] overheadCount = new int[]{0, 0, 0};
|
private int[] overheadCount = new int[]{0, 0, 0};
|
||||||
|
|
||||||
|
private List ignoredSpells = new ArrayList();
|
||||||
|
|
||||||
private List<String> getMissingMembers()
|
private List<String> getMissingMembers()
|
||||||
{
|
{
|
||||||
CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers();
|
CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers();
|
||||||
@@ -263,6 +268,8 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
panel.currentPlayers.setVisible(true);
|
panel.currentPlayers.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignoredSpells = Arrays.asList(config.hideCastIgnored().toLowerCase().split("\\s*,\\s*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -323,6 +330,9 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
panel.currentPlayers.setVisible(true);
|
panel.currentPlayers.setVisible(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "hideCastIgnored":
|
||||||
|
ignoredSpells = Arrays.asList(config.hideCastIgnored().toLowerCase().split("\\s*,\\s*"));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -430,6 +440,56 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onMenuOpened(MenuOpened event)
|
||||||
|
{
|
||||||
|
Player localPlayer = client.getLocalPlayer();
|
||||||
|
|
||||||
|
if (localPlayer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MenuEntry> menu = new ArrayList<>();
|
||||||
|
|
||||||
|
for (MenuEntry entry : event.getMenuEntries())
|
||||||
|
{
|
||||||
|
String option = Text.removeTags(entry.getOption()).toLowerCase();
|
||||||
|
String target = Text.removeTags(entry.getTarget()).toLowerCase();
|
||||||
|
|
||||||
|
int identifier = entry.getIdentifier();
|
||||||
|
|
||||||
|
Player[] players = client.getCachedPlayers();
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
if (identifier >= 0 && identifier < players.length)
|
||||||
|
{
|
||||||
|
player = players[identifier];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
menu.add(entry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option.contains("attack") && config.hideAttack() && shouldHide(config.hideAttackMode(), player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (option.contains("cast") && config.hideCast() && shouldHide(config.hideCastMode(), player)
|
||||||
|
&& !ignoredSpells.contains(StringUtils.substringBefore(target, " ->")))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
client.setMenuEntries(menu.toArray(new MenuEntry[0]));
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onFocusChanged(FocusChanged focusChanged)
|
public void onFocusChanged(FocusChanged focusChanged)
|
||||||
{
|
{
|
||||||
@@ -670,4 +730,37 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an AttackMode, checks whether or not a player should be hidden.
|
||||||
|
* @param mode The {@link AttackMode} the player should be checked against.
|
||||||
|
* @param player The player that should be checked.
|
||||||
|
* @return True if the player should be hidden, false otherwise.
|
||||||
|
*/
|
||||||
|
private boolean shouldHide(AttackMode mode, Player player)
|
||||||
|
{
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case CLAN:
|
||||||
|
if (player.isClanMember())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FRIENDS:
|
||||||
|
if (player.isFriend())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BOTH:
|
||||||
|
if (player.isClanMember() || player.isFriend())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user