Refactor PvpTools
This commit is contained in:
@@ -9,20 +9,26 @@
|
|||||||
|
|
||||||
package net.runelite.client.plugins.pvptools;
|
package net.runelite.client.plugins.pvptools;
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
import java.awt.BorderLayout;
|
||||||
import net.runelite.client.ui.FontManager;
|
import java.awt.Font;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.client.ui.FontManager;
|
||||||
|
|
||||||
public class CurrentPlayersJFrame extends JFrame
|
public class CurrentPlayersJFrame extends JFrame
|
||||||
{
|
{
|
||||||
|
|
||||||
public JList currentPlayersJList;
|
public JList<Object> currentPlayersJList;
|
||||||
|
|
||||||
CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list)
|
CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list)
|
||||||
{
|
{
|
||||||
@@ -35,7 +41,7 @@ public class CurrentPlayersJFrame extends JFrame
|
|||||||
JButton refreshJButton = new JButton("Refresh");
|
JButton refreshJButton = new JButton("Refresh");
|
||||||
refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener);
|
refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener);
|
||||||
JButton copyJButton = new JButton("Copy List");
|
JButton copyJButton = new JButton("Copy List");
|
||||||
currentPlayersJList = new JList(list.toArray());
|
currentPlayersJList = new JList<>(list.toArray());
|
||||||
ActionListener copyButtonActionListener = e ->
|
ActionListener copyButtonActionListener = e ->
|
||||||
{
|
{
|
||||||
StringSelection stringSelection;
|
StringSelection stringSelection;
|
||||||
|
|||||||
@@ -10,28 +10,25 @@
|
|||||||
package net.runelite.client.plugins.pvptools;
|
package net.runelite.client.plugins.pvptools;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Container;
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import net.runelite.api.ClanMember;
|
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
|
|
||||||
public class MissingPlayersJFrame extends JFrame
|
public class MissingPlayersJFrame extends JFrame
|
||||||
{
|
{
|
||||||
|
|
||||||
public JList missingPlayersJList;
|
public JList<Object> missingPlayersJList;
|
||||||
|
|
||||||
MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list)
|
MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list)
|
||||||
{
|
{
|
||||||
@@ -44,7 +41,7 @@ public class MissingPlayersJFrame extends JFrame
|
|||||||
JButton refreshJButton = new JButton("Refresh");
|
JButton refreshJButton = new JButton("Refresh");
|
||||||
refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener);
|
refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener);
|
||||||
JButton copyJButton = new JButton("Copy List");
|
JButton copyJButton = new JButton("Copy List");
|
||||||
missingPlayersJList = new JList(list.toArray());
|
missingPlayersJList = new JList<>(list.toArray());
|
||||||
ActionListener copyButtonActionListener = e ->
|
ActionListener copyButtonActionListener = e ->
|
||||||
{
|
{
|
||||||
StringSelection stringSelection;
|
StringSelection stringSelection;
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
package net.runelite.client.plugins.pvptools;
|
package net.runelite.client.plugins.pvptools;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.security.Key;
|
|
||||||
import net.runelite.client.config.Config;
|
import net.runelite.client.config.Config;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
@@ -33,8 +31,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
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" +
|
description = "Counts the number of each protection prayer attackable targets not in your CC are currently using",
|
||||||
" using",
|
|
||||||
position = 4
|
position = 4
|
||||||
)
|
)
|
||||||
default boolean countOverHeads()
|
default boolean countOverHeads()
|
||||||
@@ -63,7 +60,7 @@ public interface PvpToolsConfig extends Config
|
|||||||
{
|
{
|
||||||
return Keybind.NOT_SET;
|
return Keybind.NOT_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "renderSelfHotkey",
|
keyName = "renderSelfHotkey",
|
||||||
name = "Render Self Hotkey",
|
name = "Render Self Hotkey",
|
||||||
@@ -100,11 +97,11 @@ public interface PvpToolsConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
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 = 10,
|
||||||
group = "Right-Click Attack Options"
|
group = "Right-Click Attack Options"
|
||||||
)
|
)
|
||||||
default boolean levelRangeAttackOptions()
|
default boolean levelRangeAttackOptions()
|
||||||
{
|
{
|
||||||
@@ -125,18 +122,19 @@ public interface PvpToolsConfig extends Config
|
|||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
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" +
|
description = "Adds a button to the PvP Tools panel that opens a window showing which CC members are not at the current players location",
|
||||||
" the current players location",
|
|
||||||
position = 15
|
position = 15
|
||||||
)
|
)
|
||||||
default boolean missingPlayersEnabled() { return true; }
|
default boolean missingPlayersEnabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
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" +
|
description = "Adds a button to the PvP Tools panel that opens a window showing which CC members currently at the players location",
|
||||||
" the players location",
|
position = 16
|
||||||
position = 16
|
|
||||||
)
|
)
|
||||||
default boolean currentPlayersEnabled()
|
default boolean currentPlayersEnabled()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,14 +9,13 @@
|
|||||||
|
|
||||||
package net.runelite.client.plugins.pvptools;
|
package net.runelite.client.plugins.pvptools;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.BasicStroke;
|
||||||
import java.util.ArrayList;
|
import java.awt.Color;
|
||||||
import java.util.Arrays;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Polygon;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import net.runelite.api.Actor;
|
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Player;
|
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
@@ -40,7 +39,7 @@ public class PvpToolsOverlay extends Overlay
|
|||||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||||
setPriority(OverlayPriority.HIGH);
|
setPriority(OverlayPriority.HIGH);
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -33,21 +33,18 @@ public class PvpToolsPanel extends PluginPanel
|
|||||||
|
|
||||||
private final JLabel loggedLabel = new JLabel();
|
private final JLabel loggedLabel = new JLabel();
|
||||||
private final JRichTextPane emailLabel = new JRichTextPane();
|
private final JRichTextPane emailLabel = new JRichTextPane();
|
||||||
public JLabel numCC = new JLabel();
|
JLabel numCC = new JLabel();
|
||||||
public JLabel numOther = new JLabel();
|
JLabel numOther = new JLabel();
|
||||||
public JLabel numMageJLabel = new JLabel(" ");
|
JLabel numMageJLabel = new JLabel(" ");
|
||||||
public JLabel numRangeJLabel = new JLabel(" ");
|
JLabel numRangeJLabel = new JLabel(" ");
|
||||||
public JLabel numMeleeJLabel = new JLabel(" ");
|
JLabel numMeleeJLabel = new JLabel(" ");
|
||||||
public JLabel totalRiskLabel = new JLabel(" ");
|
JLabel totalRiskLabel = new JLabel(" ");
|
||||||
public JLabel riskProtectingItem = new JLabel(" ");
|
JLabel riskProtectingItem = new JLabel(" ");
|
||||||
public JLabel biggestItemLabel = new JLabel("Protected Item: ");
|
JLabel biggestItemLabel = new JLabel("Protected Item: ");
|
||||||
public JButton missingPlayers = new JButton("Show missing CC members");
|
JButton missingPlayers = new JButton("Show missing CC members");
|
||||||
public JButton currentPlayers = new JButton("Show current CC members");
|
JButton currentPlayers = new JButton("Show current CC members");
|
||||||
public JLabel numBrews = new JLabel();
|
private JLabel numBrews = new JLabel();
|
||||||
@Inject
|
|
||||||
private JPanel pvpToolsPanel = new JPanel(new GridLayout(11, 1));
|
|
||||||
private JPanel missingPlayersPanel = new JPanel();
|
private JPanel missingPlayersPanel = new JPanel();
|
||||||
private JPanel currentPlayersPanel = new JPanel();
|
|
||||||
|
|
||||||
|
|
||||||
public static String htmlLabel(String key, String value)
|
public static String htmlLabel(String key, String value)
|
||||||
@@ -62,7 +59,6 @@ public class PvpToolsPanel extends PluginPanel
|
|||||||
setBorder(new EmptyBorder(10, 10, 10, 10));
|
setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JPanel versionPanel = new JPanel();
|
JPanel versionPanel = new JPanel();
|
||||||
versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
@@ -136,7 +132,7 @@ public class PvpToolsPanel extends PluginPanel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disablePlayerCount()
|
void disablePlayerCount()
|
||||||
{
|
{
|
||||||
this.numOther.setText("Disabled");
|
this.numOther.setText("Disabled");
|
||||||
this.numCC.setText("Disabled");
|
this.numCC.setText("Disabled");
|
||||||
@@ -144,7 +140,7 @@ public class PvpToolsPanel extends PluginPanel
|
|||||||
this.numOther.repaint();
|
this.numOther.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disablePrayerCount()
|
void disablePrayerCount()
|
||||||
{
|
{
|
||||||
this.numMageJLabel.setText("disabled");
|
this.numMageJLabel.setText("disabled");
|
||||||
this.numRangeJLabel.setText("disabled");
|
this.numRangeJLabel.setText("disabled");
|
||||||
@@ -154,7 +150,7 @@ public class PvpToolsPanel extends PluginPanel
|
|||||||
this.numMeleeJLabel.repaint();
|
this.numMeleeJLabel.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableRiskCalculator()
|
void disableRiskCalculator()
|
||||||
{
|
{
|
||||||
this.totalRiskLabel.setText("disabled");
|
this.totalRiskLabel.setText("disabled");
|
||||||
this.riskProtectingItem.setText("disabled");
|
this.riskProtectingItem.setText("disabled");
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import java.util.NavigableMap;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
@@ -45,13 +44,11 @@ import net.runelite.api.events.PlayerSpawned;
|
|||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.game.AsyncBufferedImage;
|
import net.runelite.client.game.AsyncBufferedImage;
|
||||||
import net.runelite.client.game.ClanManager;
|
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.input.KeyManager;
|
import net.runelite.client.input.KeyManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.PluginType;
|
import net.runelite.client.plugins.PluginType;
|
||||||
import net.runelite.client.plugins.PluginManager;
|
|
||||||
import net.runelite.client.plugins.clanchat.ClanChatPlugin;
|
import net.runelite.client.plugins.clanchat.ClanChatPlugin;
|
||||||
import static net.runelite.client.plugins.pvptools.PvpToolsPanel.htmlLabel;
|
import static net.runelite.client.plugins.pvptools.PvpToolsPanel.htmlLabel;
|
||||||
import net.runelite.client.ui.ClientToolbar;
|
import net.runelite.client.ui.ClientToolbar;
|
||||||
@@ -74,25 +71,30 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
PvpToolsOverlay pvpToolsOverlay;
|
PvpToolsOverlay pvpToolsOverlay;
|
||||||
|
|
||||||
boolean fallinHelperEnabled = false;
|
boolean fallinHelperEnabled = false;
|
||||||
private PvpToolsPanel panel;
|
private PvpToolsPanel panel;
|
||||||
private MissingPlayersJFrame missingPlayersJFrame;
|
private MissingPlayersJFrame missingPlayersJFrame;
|
||||||
private CurrentPlayersJFrame currentPlayersJFrame;
|
private CurrentPlayersJFrame currentPlayersJFrame;
|
||||||
private NavigationButton navButton;
|
private NavigationButton navButton;
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
private boolean attackHotKeyPressed;
|
private boolean attackHotKeyPressed;
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
private boolean hideAll;
|
private boolean hideAll;
|
||||||
@Inject
|
|
||||||
private ScheduledExecutorService executorService;
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ItemManager itemManager;
|
private ItemManager itemManager;
|
||||||
|
|
||||||
private PvpToolsPlugin uhPvpToolsPlugin = this;
|
private PvpToolsPlugin uhPvpToolsPlugin = this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,15 +146,6 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private PvpToolsConfig config;
|
private PvpToolsConfig config;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PluginManager pluginManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ClanManager clanManager;
|
|
||||||
|
|
||||||
|
|
||||||
private ClanChatPlugin clanChatPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HotKeyListener for the hot key assigned in the config that triggers the Fall In Helper feature
|
* The HotKeyListener for the hot key assigned in the config that triggers the Fall In Helper feature
|
||||||
*/
|
*/
|
||||||
@@ -163,7 +156,7 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
toggleFallinHelper();
|
toggleFallinHelper();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final HotkeyListener renderselfHotkeyListener = new HotkeyListener(() -> config.renderSelf())
|
private final HotkeyListener renderselfHotkeyListener = new HotkeyListener(() -> config.renderSelf())
|
||||||
{
|
{
|
||||||
public void hotkeyPressed()
|
public void hotkeyPressed()
|
||||||
@@ -174,23 +167,11 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
|
|
||||||
private int[] overheadCount = new int[]{0, 0, 0};
|
private int[] overheadCount = new int[]{0, 0, 0};
|
||||||
|
|
||||||
private Comparator<Item> itemPriceComparator = new Comparator<Item>()
|
private List<String> getMissingMembers()
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int compare(Item o1, Item o2)
|
|
||||||
{
|
|
||||||
return (itemManager.getItemPrice(itemManager.getItemComposition(o1.getId()).getPrice())
|
|
||||||
- itemManager.getItemPrice(itemManager.getItemComposition(o2.getId()).getPrice()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private String mtarget;
|
|
||||||
|
|
||||||
public List getMissingMembers()
|
|
||||||
{
|
{
|
||||||
CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers();
|
CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers();
|
||||||
ArrayList missingMembers = new ArrayList();
|
ArrayList<String> missingMembers = new ArrayList<>();
|
||||||
for (ClanMember clanMember:client.getClanMembers())
|
for (ClanMember clanMember : client.getClanMembers())
|
||||||
{
|
{
|
||||||
if (!Objects.isNull(clanMember))
|
if (!Objects.isNull(clanMember))
|
||||||
{
|
{
|
||||||
@@ -206,16 +187,13 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
return missingMembers;
|
return missingMembers;
|
||||||
|
|
||||||
//Arrays.stream(Arrays.stream(client.getClanMembers()).filter(Objects::nonNull).map(ClanMember::getUsername)
|
|
||||||
//.toArray()).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getCurrentMembers()
|
private List<String> getCurrentMembers()
|
||||||
{
|
{
|
||||||
CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers();
|
CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers();
|
||||||
ArrayList currentMembers = new ArrayList();
|
ArrayList<String> currentMembers = new ArrayList<>();
|
||||||
for (ClanMember clanMember:client.getClanMembers())
|
for (ClanMember clanMember : client.getClanMembers())
|
||||||
{
|
{
|
||||||
if (!Objects.isNull(clanMember))
|
if (!Objects.isNull(clanMember))
|
||||||
{
|
{
|
||||||
@@ -231,13 +209,9 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
return currentMembers;
|
return currentMembers;
|
||||||
|
|
||||||
//Arrays.stream(Arrays.stream(client.getClanMembers()).filter(Objects::nonNull).map(ClanMember::getUsername)
|
|
||||||
//.toArray()).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
PvpToolsConfig config(ConfigManager configManager)
|
PvpToolsConfig config(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -247,7 +221,6 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
overlayManager.add(pvpToolsOverlay);
|
overlayManager.add(pvpToolsOverlay);
|
||||||
|
|
||||||
keyManager.registerKeyListener(fallinHotkeyListener);
|
keyManager.registerKeyListener(fallinHotkeyListener);
|
||||||
@@ -399,79 +372,56 @@ public class PvpToolsPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
|
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
|
||||||
{
|
{
|
||||||
if (config.attackOptionsFriend() || config.attackOptionsClan() || config.levelRangeAttackOptions())
|
if (config.attackOptionsFriend() || config.attackOptionsClan() || config.levelRangeAttackOptions())
|
||||||
|
{
|
||||||
|
if (client.getGameState() != GameState.LOGGED_IN)
|
||||||
{
|
{
|
||||||
if (client.getGameState() != GameState.LOGGED_IN)
|
return;
|
||||||
|
}
|
||||||
|
Player[] players = client.getCachedPlayers();
|
||||||
|
Player player = null;
|
||||||
|
int identifier = menuEntryAdded.getIdentifier();
|
||||||
|
if (identifier >= 0 && identifier < players.length)
|
||||||
|
{
|
||||||
|
player = players[identifier];
|
||||||
|
}
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (attackHotKeyPressed && config.attackOptionsClan() || config.attackOptionsFriend() ||
|
||||||
|
config.levelRangeAttackOptions())
|
||||||
|
{
|
||||||
|
if (config.attackOptionsFriend() && player.isFriend())
|
||||||
{
|
{
|
||||||
return;
|
moveEntry();
|
||||||
}
|
}
|
||||||
Player[] players = client.getCachedPlayers();
|
if (config.attackOptionsClan() && player.isClanMember())
|
||||||
Player player = null;
|
|
||||||
int identifier = menuEntryAdded.getIdentifier();
|
|
||||||
if (identifier >= 0 && identifier < players.length)
|
|
||||||
{
|
{
|
||||||
player = players[identifier];
|
moveEntry();
|
||||||
}
|
}
|
||||||
if (player == null)
|
if (config.levelRangeAttackOptions() && !PvPUtil.isAttackable(client, player))
|
||||||
{
|
{
|
||||||
return;
|
moveEntry();
|
||||||
}
|
|
||||||
final String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase();
|
|
||||||
final String mtarget = Text.removeTags(menuEntryAdded.getTarget()).toLowerCase();
|
|
||||||
if (attackHotKeyPressed && config.attackOptionsClan() || config.attackOptionsFriend() ||
|
|
||||||
config.levelRangeAttackOptions())
|
|
||||||
{
|
|
||||||
if (config.attackOptionsFriend() && player.isFriend())
|
|
||||||
{
|
|
||||||
moveEntry(mtarget);
|
|
||||||
}
|
|
||||||
if (config.attackOptionsClan() && player.isClanMember())
|
|
||||||
{
|
|
||||||
moveEntry(mtarget);
|
|
||||||
}
|
|
||||||
if (config.levelRangeAttackOptions() && !PvPUtil.isAttackable(client, player))
|
|
||||||
{
|
|
||||||
moveEntry(mtarget);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveEntry(String mtarget)
|
private void moveEntry()
|
||||||
{
|
{
|
||||||
this.mtarget = mtarget;
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
|
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
|
||||||
|
|
||||||
// strip out existing <col...
|
|
||||||
String target = lastEntry.getTarget();
|
|
||||||
int idx = target.indexOf('>');
|
|
||||||
if (idx != -1)
|
|
||||||
{
|
|
||||||
target = target.substring(idx + 1);
|
|
||||||
}
|
|
||||||
/*System.out.println("Contents : " + lastEntry.getTarget());
|
|
||||||
System.out.println("Contents : " + lastEntry.getIdentifier());
|
|
||||||
System.out.println("Contents : " + lastEntry.getOption());
|
|
||||||
System.out.println("length : " + menuEntries.length);*/
|
|
||||||
if (menuEntries[menuEntries.length - 1] != null)
|
|
||||||
{
|
|
||||||
//System.out.println(menuEntries.length + ": " + menuEntries[menuEntries.length-1]);
|
|
||||||
}
|
|
||||||
if (lastEntry.getOption().contains("attack".toLowerCase()))
|
if (lastEntry.getOption().contains("attack".toLowerCase()))
|
||||||
{
|
{
|
||||||
ArrayUtils.shift(menuEntries, 1);
|
ArrayUtils.shift(menuEntries, 1);
|
||||||
//ArrayUtils.add(menuEntries, menuEntries.length - 2);
|
|
||||||
//menuEntries = ArrayUtils.remove(menuEntries, menuEntries.length - 1);
|
|
||||||
//menuEntrySwapperPlugin.swap("attack", option, mtarget, false);
|
|
||||||
}
|
}
|
||||||
if (lastEntry.getOption().equals("Attack"))
|
if (lastEntry.getOption().equals("Attack"))
|
||||||
{
|
{
|
||||||
ArrayUtils.shift(menuEntries, 1);
|
ArrayUtils.shift(menuEntries, 1);
|
||||||
|
|
||||||
//menuEntries = ArrayUtils.sremove(menuEntries, menuEntries.length - 1);
|
|
||||||
//menuEntrySwapperPlugin.swap("attack", option, mtarget, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.setMenuEntries(menuEntries);
|
client.setMenuEntries(menuEntries);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user