Merge remote-tracking branch 'upstream/master' into master
This commit is contained in:
@@ -169,6 +169,7 @@ public enum AgilityShortcut
|
|||||||
SLAYER_DUNGEON_CREVICE(62, "Narrow Crevice", new WorldPoint(2729, 10008, 0), CREVICE_16539),
|
SLAYER_DUNGEON_CREVICE(62, "Narrow Crevice", new WorldPoint(2729, 10008, 0), CREVICE_16539),
|
||||||
MOUNT_KARUULM_UPPER(62, "Rocks", new WorldPoint(1322, 3791, 0), ROCKS_34396),
|
MOUNT_KARUULM_UPPER(62, "Rocks", new WorldPoint(1322, 3791, 0), ROCKS_34396),
|
||||||
TAVERLEY_DUNGEON_RAILING(63, "Loose Railing", new WorldPoint(2935, 9811, 0), LOOSE_RAILING_28849),
|
TAVERLEY_DUNGEON_RAILING(63, "Loose Railing", new WorldPoint(2935, 9811, 0), LOOSE_RAILING_28849),
|
||||||
|
DARKMEYER_WALL(63, "Wall (Long rope)", new WorldPoint(3669, 3375, 0), NULL_39541, NULL_39542),
|
||||||
TROLLHEIM_WILDERNESS_ROCKS_EAST(64, "Rocks", new WorldPoint(2945, 3678, 0), ROCKS_16545),
|
TROLLHEIM_WILDERNESS_ROCKS_EAST(64, "Rocks", new WorldPoint(2945, 3678, 0), ROCKS_16545),
|
||||||
TROLLHEIM_WILDERNESS_ROCKS_WEST(64, "Rocks", new WorldPoint(2917, 3672, 0), ROCKS_16545),
|
TROLLHEIM_WILDERNESS_ROCKS_WEST(64, "Rocks", new WorldPoint(2917, 3672, 0), ROCKS_16545),
|
||||||
FOSSIL_ISLAND_VOLCANO(64, "Rope", new WorldPoint(3780, 3822, 0), ROPE_ANCHOR, ROPE_ANCHOR_30917),
|
FOSSIL_ISLAND_VOLCANO(64, "Rope", new WorldPoint(3780, 3822, 0), ROPE_ANCHOR, ROPE_ANCHOR_30917),
|
||||||
|
|||||||
@@ -28,12 +28,44 @@ package net.runelite.client.plugins.chatnotifications;
|
|||||||
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;
|
||||||
|
import net.runelite.client.config.ConfigSection;
|
||||||
|
|
||||||
@ConfigGroup("chatnotification")
|
@ConfigGroup("chatnotification")
|
||||||
public interface ChatNotificationsConfig extends Config
|
public interface ChatNotificationsConfig extends Config
|
||||||
{
|
{
|
||||||
|
@ConfigSection(
|
||||||
|
name = "Highlight Lists",
|
||||||
|
description = "Custom single word and regex filter lists",
|
||||||
|
position = 0
|
||||||
|
)
|
||||||
|
String highlightLists = "highlightLists";
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 0,
|
position = 1,
|
||||||
|
keyName = "highlightWordsString",
|
||||||
|
name = "Highlight words",
|
||||||
|
description = "Highlights the following words in chat",
|
||||||
|
section = highlightLists
|
||||||
|
)
|
||||||
|
default String highlightWordsString()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 2,
|
||||||
|
keyName = "highlightRegexString",
|
||||||
|
name = "Highlight Regex",
|
||||||
|
description = "Highlights the following regular expressions in chat, one per line",
|
||||||
|
section = highlightLists
|
||||||
|
)
|
||||||
|
default String highlightRegexString()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 1,
|
||||||
keyName = "highlightOwnName",
|
keyName = "highlightOwnName",
|
||||||
name = "Highlight own name",
|
name = "Highlight own name",
|
||||||
description = "Highlights any instance of your username in chat"
|
description = "Highlights any instance of your username in chat"
|
||||||
@@ -43,17 +75,6 @@ public interface ChatNotificationsConfig extends Config
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
position = 1,
|
|
||||||
keyName = "highlightWordsString",
|
|
||||||
name = "Highlight words",
|
|
||||||
description = "Highlights the following words in chat"
|
|
||||||
)
|
|
||||||
default String highlightWordsString()
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 2,
|
position = 2,
|
||||||
keyName = "notifyOnOwnName",
|
keyName = "notifyOnOwnName",
|
||||||
|
|||||||
@@ -27,12 +27,16 @@ package net.runelite.client.plugins.chatnotifications;
|
|||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.regex.PatternSyntaxException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@@ -77,7 +81,7 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
|
|
||||||
//Custom Highlights
|
//Custom Highlights
|
||||||
private Pattern usernameMatcher = null;
|
private Pattern usernameMatcher = null;
|
||||||
private Pattern highlightMatcher = null;
|
private final List<Pattern> highlightPatterns = new ArrayList<>();
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
ChatNotificationsConfig provideConfig(ConfigManager configManager)
|
ChatNotificationsConfig provideConfig(ConfigManager configManager)
|
||||||
@@ -91,6 +95,13 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
updateHighlights();
|
updateHighlights();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shutDown()
|
||||||
|
{
|
||||||
|
usernameMatcher = null;
|
||||||
|
highlightPatterns.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameStateChanged(GameStateChanged event)
|
public void onGameStateChanged(GameStateChanged event)
|
||||||
{
|
{
|
||||||
@@ -114,7 +125,7 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
|
|
||||||
private void updateHighlights()
|
private void updateHighlights()
|
||||||
{
|
{
|
||||||
highlightMatcher = null;
|
highlightPatterns.clear();
|
||||||
|
|
||||||
if (!config.highlightWordsString().trim().equals(""))
|
if (!config.highlightWordsString().trim().equals(""))
|
||||||
{
|
{
|
||||||
@@ -125,7 +136,28 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
.collect(Collectors.joining("|"));
|
.collect(Collectors.joining("|"));
|
||||||
// To match <word> \b doesn't work due to <> not being in \w,
|
// To match <word> \b doesn't work due to <> not being in \w,
|
||||||
// so match \b or \s, as well as \A and \z for beginning and end of input respectively
|
// so match \b or \s, as well as \A and \z for beginning and end of input respectively
|
||||||
highlightMatcher = Pattern.compile("(?:\\b|(?<=\\s)|\\A)(?:" + joined + ")(?:\\b|(?=\\s)|\\z)", Pattern.CASE_INSENSITIVE);
|
highlightPatterns.add(Pattern.compile("(?:\\b|(?<=\\s)|\\A)(?:" + joined + ")(?:\\b|(?=\\s)|\\z)", Pattern.CASE_INSENSITIVE));
|
||||||
|
}
|
||||||
|
|
||||||
|
Splitter
|
||||||
|
.on("\n")
|
||||||
|
.omitEmptyStrings()
|
||||||
|
.trimResults()
|
||||||
|
.splitToList(config.highlightRegexString()).stream()
|
||||||
|
.map(ChatNotificationsPlugin::compilePattern)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.forEach(highlightPatterns::add);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Pattern compilePattern(String pattern)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
|
||||||
|
}
|
||||||
|
catch (PatternSyntaxException ex)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,14 +257,22 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlightMatcher != null)
|
boolean matchesHighlight = false;
|
||||||
|
// Get nodeValue to store and update in between the different pattern passes
|
||||||
|
// The messageNode value is only set after all patterns have been processed
|
||||||
|
String nodeValue = messageNode.getValue();
|
||||||
|
|
||||||
|
for (Pattern pattern : highlightPatterns)
|
||||||
{
|
{
|
||||||
String nodeValue = messageNode.getValue();
|
Matcher matcher = pattern.matcher(nodeValue);
|
||||||
Matcher matcher = highlightMatcher.matcher(nodeValue);
|
if (!matcher.find())
|
||||||
boolean found = false;
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
|
||||||
while (matcher.find())
|
do
|
||||||
{
|
{
|
||||||
String value = matcher.group();
|
String value = matcher.group();
|
||||||
|
|
||||||
@@ -256,18 +296,21 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
stringBuffer.append(endColor == null ? "<col" + ChatColorType.NORMAL + ">" : endColor);
|
stringBuffer.append(endColor == null ? "<col" + ChatColorType.NORMAL + ">" : endColor);
|
||||||
|
|
||||||
update = true;
|
update = true;
|
||||||
found = true;
|
matchesHighlight = true;
|
||||||
}
|
}
|
||||||
|
while (matcher.find());
|
||||||
|
|
||||||
if (found)
|
// Append stringBuffer with remainder of message and update nodeValue
|
||||||
|
matcher.appendTail(stringBuffer);
|
||||||
|
nodeValue = stringBuffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchesHighlight)
|
||||||
|
{
|
||||||
|
messageNode.setValue(nodeValue);
|
||||||
|
if (config.notifyOnHighlight())
|
||||||
{
|
{
|
||||||
matcher.appendTail(stringBuffer);
|
sendNotification(chatMessage);
|
||||||
messageNode.setValue(stringBuffer.toString());
|
|
||||||
|
|
||||||
if (config.notifyOnHighlight())
|
|
||||||
{
|
|
||||||
sendNotification(chatMessage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ enum DiscordGameEventType
|
|||||||
DUNGEON_OURANIA("Ourania Cave", DiscordAreaType.DUNGEONS, 12119),
|
DUNGEON_OURANIA("Ourania Cave", DiscordAreaType.DUNGEONS, 12119),
|
||||||
DUNGEON_QUIDAMORTEM_CAVE("Quidamortem Cave", DiscordAreaType.DUNGEONS, 4763),
|
DUNGEON_QUIDAMORTEM_CAVE("Quidamortem Cave", DiscordAreaType.DUNGEONS, 4763),
|
||||||
DUNGEON_RASHILIYIAS_TOMB("Rashiliyta's Tomb", DiscordAreaType.DUNGEONS, 11668),
|
DUNGEON_RASHILIYIAS_TOMB("Rashiliyta's Tomb", DiscordAreaType.DUNGEONS, 11668),
|
||||||
|
DUNGEON_SALT_MINE("Salt Mine", DiscordAreaType.DUNGEONS, 11425),
|
||||||
DUNGEON_SARADOMINSHRINE("Saradomin Shrine (Paterdomus)", DiscordAreaType.DUNGEONS, 13722),
|
DUNGEON_SARADOMINSHRINE("Saradomin Shrine (Paterdomus)", DiscordAreaType.DUNGEONS, 13722),
|
||||||
DUNGEON_SHADE_CATACOMBS("Shade Catacombs", DiscordAreaType.DUNGEONS, 13975),
|
DUNGEON_SHADE_CATACOMBS("Shade Catacombs", DiscordAreaType.DUNGEONS, 13975),
|
||||||
DUNGEON_SHADOW("Shadow Dungeon", DiscordAreaType.DUNGEONS, 10575, 10831),
|
DUNGEON_SHADOW("Shadow Dungeon", DiscordAreaType.DUNGEONS, 10575, 10831),
|
||||||
@@ -294,7 +295,7 @@ enum DiscordGameEventType
|
|||||||
MG_PEST_CONTROL("Pest Control", DiscordAreaType.MINIGAMES, 10536),
|
MG_PEST_CONTROL("Pest Control", DiscordAreaType.MINIGAMES, 10536),
|
||||||
MG_PORT_SARIM_RAT_PITS("Port Sarim Rat Pits", DiscordAreaType.MINIGAMES, 11926),
|
MG_PORT_SARIM_RAT_PITS("Port Sarim Rat Pits", DiscordAreaType.MINIGAMES, 11926),
|
||||||
MG_PYRAMID_PLUNDER("Pyramid Plunder", DiscordAreaType.MINIGAMES, 7749),
|
MG_PYRAMID_PLUNDER("Pyramid Plunder", DiscordAreaType.MINIGAMES, 7749),
|
||||||
MG_ROGUES_DEN("Rogues' Den", DiscordAreaType.MINIGAMES, 11855, 11854, 12111, 12110),
|
MG_ROGUES_DEN("Rogues' Den", DiscordAreaType.MINIGAMES, 11854, 11855, 12109, 12110, 12111),
|
||||||
MG_SORCERESS_GARDEN("Sorceress's Garden", DiscordAreaType.MINIGAMES, 11605),
|
MG_SORCERESS_GARDEN("Sorceress's Garden", DiscordAreaType.MINIGAMES, 11605),
|
||||||
MG_SOUL_WARS("Soul Wars", DiscordAreaType.MINIGAMES, 8493, 8748, 8749, 9005),
|
MG_SOUL_WARS("Soul Wars", DiscordAreaType.MINIGAMES, 8493, 8748, 8749, 9005),
|
||||||
MG_TEMPLE_TREKKING("Temple Trekking", DiscordAreaType.MINIGAMES, 8014, 8270, 8256, 8782, 9038, 9294, 9550, 9806),
|
MG_TEMPLE_TREKKING("Temple Trekking", DiscordAreaType.MINIGAMES, 8014, 8270, 8256, 8782, 9038, 9294, 9550, 9806),
|
||||||
@@ -424,6 +425,7 @@ enum DiscordGameEventType
|
|||||||
REGION_TROLLWEISS_MTN("Trollweiss Mountain", DiscordAreaType.REGIONS, 11066, 11067, 11068),
|
REGION_TROLLWEISS_MTN("Trollweiss Mountain", DiscordAreaType.REGIONS, 11066, 11067, 11068),
|
||||||
REGION_UNDERWATER("Underwater", DiscordAreaType.REGIONS, 15008, 15264),
|
REGION_UNDERWATER("Underwater", DiscordAreaType.REGIONS, 15008, 15264),
|
||||||
REGION_WATER_ALTAR("Water Altar", DiscordAreaType.REGIONS, 10827),
|
REGION_WATER_ALTAR("Water Altar", DiscordAreaType.REGIONS, 10827),
|
||||||
|
REGION_WATERBIRTH_ISLAND("Waterbirth Island", DiscordAreaType.REGIONS, 10042),
|
||||||
REGION_WINTERTODT_CAMP("Wintertodt Camp", DiscordAreaType.REGIONS, 6461),
|
REGION_WINTERTODT_CAMP("Wintertodt Camp", DiscordAreaType.REGIONS, 6461),
|
||||||
REGION_WIZARDS_TOWER("Wizards' Tower", DiscordAreaType.REGIONS, 12337),
|
REGION_WIZARDS_TOWER("Wizards' Tower", DiscordAreaType.REGIONS, 12337),
|
||||||
REGION_WOODCUTTING_GUILD("Woodcutting Guild", DiscordAreaType.REGIONS, 6198, 6454),
|
REGION_WOODCUTTING_GUILD("Woodcutting Guild", DiscordAreaType.REGIONS, 6198, 6454),
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ class GrandExchangeItemPanel extends JPanel
|
|||||||
{
|
{
|
||||||
private static final Dimension ICON_SIZE = new Dimension(32, 32);
|
private static final Dimension ICON_SIZE = new Dimension(32, 32);
|
||||||
|
|
||||||
GrandExchangeItemPanel(AsyncBufferedImage icon, String name, int itemID, int gePrice, Double
|
GrandExchangeItemPanel(GrandExchangePlugin grandExchangePlugin, AsyncBufferedImage icon, String name, int itemID,
|
||||||
haPrice, int geItemLimit)
|
int gePrice, int haPrice, int geItemLimit)
|
||||||
{
|
{
|
||||||
BorderLayout layout = new BorderLayout();
|
BorderLayout layout = new BorderLayout();
|
||||||
layout.setHgap(5);
|
layout.setHgap(5);
|
||||||
@@ -89,7 +89,7 @@ class GrandExchangeItemPanel extends JPanel
|
|||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e)
|
public void mouseReleased(MouseEvent e)
|
||||||
{
|
{
|
||||||
GrandExchangePlugin.openGeLink(name, itemID);
|
grandExchangePlugin.openGeLink(name, itemID);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ class GrandExchangeItemPanel extends JPanel
|
|||||||
|
|
||||||
// Alch price
|
// Alch price
|
||||||
JLabel haPriceLabel = new JLabel();
|
JLabel haPriceLabel = new JLabel();
|
||||||
haPriceLabel.setText(QuantityFormatter.formatNumber(haPrice.intValue()) + " alch");
|
haPriceLabel.setText(QuantityFormatter.formatNumber(haPrice) + " alch");
|
||||||
haPriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_ALCH);
|
haPriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_ALCH);
|
||||||
alchAndLimitPanel.add(haPriceLabel, BorderLayout.WEST);
|
alchAndLimitPanel.add(haPriceLabel, BorderLayout.WEST);
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,6 @@ class GrandExchangeItems
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final int itemId;
|
private final int itemId;
|
||||||
private final int gePrice;
|
private final int gePrice;
|
||||||
private final double haPrice;
|
private final int haPrice;
|
||||||
private final int geItemLimit;
|
private final int geItemLimit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ public class GrandExchangeOfferSlot extends JPanel
|
|||||||
private static final ImageIcon RIGHT_ARROW_ICON;
|
private static final ImageIcon RIGHT_ARROW_ICON;
|
||||||
private static final ImageIcon LEFT_ARROW_ICON;
|
private static final ImageIcon LEFT_ARROW_ICON;
|
||||||
|
|
||||||
|
private final GrandExchangePlugin grandExchangePlugin;
|
||||||
|
|
||||||
private final JPanel container = new JPanel();
|
private final JPanel container = new JPanel();
|
||||||
private final CardLayout cardLayout = new CardLayout();
|
private final CardLayout cardLayout = new CardLayout();
|
||||||
|
|
||||||
@@ -91,8 +93,10 @@ public class GrandExchangeOfferSlot extends JPanel
|
|||||||
* This (sub)panel is used for each GE slot displayed
|
* This (sub)panel is used for each GE slot displayed
|
||||||
* in the sidebar
|
* in the sidebar
|
||||||
*/
|
*/
|
||||||
GrandExchangeOfferSlot()
|
GrandExchangeOfferSlot(GrandExchangePlugin grandExchangePlugin)
|
||||||
{
|
{
|
||||||
|
this.grandExchangePlugin = grandExchangePlugin;
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
setBorder(new EmptyBorder(7, 0, 0, 0));
|
setBorder(new EmptyBorder(7, 0, 0, 0));
|
||||||
@@ -235,7 +239,7 @@ public class GrandExchangeOfferSlot extends JPanel
|
|||||||
popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
|
popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
final JMenuItem openGeLink = new JMenuItem("Open Grand Exchange website");
|
final JMenuItem openGeLink = new JMenuItem("Open Grand Exchange website");
|
||||||
openGeLink.addActionListener(e -> GrandExchangePlugin.openGeLink(offerItem.getName(), offerItem.getId()));
|
openGeLink.addActionListener(e -> grandExchangePlugin.openGeLink(offerItem.getName(), offerItem.getId()));
|
||||||
popupMenu.add(openGeLink);
|
popupMenu.add(openGeLink);
|
||||||
|
|
||||||
/* Couldn't set the tooltip for the container panel as the children override it, so I'm setting
|
/* Couldn't set the tooltip for the container panel as the children override it, so I'm setting
|
||||||
@@ -252,7 +256,6 @@ public class GrandExchangeOfferSlot extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
revalidate();
|
revalidate();
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String htmlTooltip(String value)
|
private String htmlTooltip(String value)
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import java.awt.CardLayout;
|
|||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import net.runelite.api.GrandExchangeOffer;
|
import net.runelite.api.GrandExchangeOffer;
|
||||||
@@ -45,6 +47,8 @@ class GrandExchangeOffersPanel extends JPanel
|
|||||||
|
|
||||||
private static final int MAX_OFFERS = 8;
|
private static final int MAX_OFFERS = 8;
|
||||||
|
|
||||||
|
private final GrandExchangePlugin grandExchangePlugin;
|
||||||
|
|
||||||
private final GridBagConstraints constraints = new GridBagConstraints();
|
private final GridBagConstraints constraints = new GridBagConstraints();
|
||||||
private final CardLayout cardLayout = new CardLayout();
|
private final CardLayout cardLayout = new CardLayout();
|
||||||
|
|
||||||
@@ -56,8 +60,11 @@ class GrandExchangeOffersPanel extends JPanel
|
|||||||
|
|
||||||
private final GrandExchangeOfferSlot[] offerSlotPanels = new GrandExchangeOfferSlot[MAX_OFFERS];
|
private final GrandExchangeOfferSlot[] offerSlotPanels = new GrandExchangeOfferSlot[MAX_OFFERS];
|
||||||
|
|
||||||
GrandExchangeOffersPanel()
|
@Inject
|
||||||
|
private GrandExchangeOffersPanel(final GrandExchangePlugin grandExchangePlugin)
|
||||||
{
|
{
|
||||||
|
this.grandExchangePlugin = grandExchangePlugin;
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
|
|
||||||
@@ -96,10 +103,7 @@ class GrandExchangeOffersPanel extends JPanel
|
|||||||
void resetOffers()
|
void resetOffers()
|
||||||
{
|
{
|
||||||
offerPanel.removeAll();
|
offerPanel.removeAll();
|
||||||
for (int i = 0; i < offerSlotPanels.length; i++)
|
Arrays.fill(offerSlotPanels, null);
|
||||||
{
|
|
||||||
offerSlotPanels[i] = null;
|
|
||||||
}
|
|
||||||
updateEmptyOffersPanel();
|
updateEmptyOffersPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,15 +126,16 @@ class GrandExchangeOffersPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If slot was empty, and is now filled, add it to the list */
|
/* If slot was empty, and is now filled, add it to the list */
|
||||||
if (offerSlotPanels[slot] == null)
|
GrandExchangeOfferSlot offerSlot = offerSlotPanels[slot];
|
||||||
|
if (offerSlot == null)
|
||||||
{
|
{
|
||||||
GrandExchangeOfferSlot newSlot = new GrandExchangeOfferSlot();
|
offerSlot = new GrandExchangeOfferSlot(grandExchangePlugin);
|
||||||
offerSlotPanels[slot] = newSlot;
|
offerSlotPanels[slot] = offerSlot;
|
||||||
offerPanel.add(newSlot, constraints);
|
offerPanel.add(offerSlot, constraints);
|
||||||
constraints.gridy++;
|
constraints.gridy++;
|
||||||
}
|
}
|
||||||
|
|
||||||
offerSlotPanels[slot].updateOffer(item, itemImage, newOffer);
|
offerSlot.updateOffer(item, itemImage, newOffer);
|
||||||
|
|
||||||
removeTopMargin();
|
removeTopMargin();
|
||||||
|
|
||||||
|
|||||||
@@ -48,21 +48,19 @@ class GrandExchangePanel extends PluginPanel
|
|||||||
@Getter
|
@Getter
|
||||||
private final GrandExchangeSearchPanel searchPanel;
|
private final GrandExchangeSearchPanel searchPanel;
|
||||||
@Getter
|
@Getter
|
||||||
private GrandExchangeOffersPanel offersPanel;
|
private final GrandExchangeOffersPanel offersPanel;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private GrandExchangePanel(GrandExchangeSearchPanel searchPanel)
|
private GrandExchangePanel(GrandExchangeSearchPanel searchPanel, GrandExchangeOffersPanel offersPanel)
|
||||||
{
|
{
|
||||||
super(false);
|
super(false);
|
||||||
|
|
||||||
this.searchPanel = searchPanel;
|
this.searchPanel = searchPanel;
|
||||||
|
this.offersPanel = offersPanel;
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
|
|
||||||
//Offers Panel
|
|
||||||
offersPanel = new GrandExchangeOffersPanel();
|
|
||||||
|
|
||||||
MaterialTab offersTab = new MaterialTab("Offers", tabGroup, offersPanel);
|
MaterialTab offersTab = new MaterialTab("Offers", tabGroup, offersPanel);
|
||||||
searchTab = new MaterialTab("Search", tabGroup, searchPanel);
|
searchTab = new MaterialTab("Search", tabGroup, searchPanel);
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ import net.runelite.client.Notifier;
|
|||||||
import net.runelite.client.account.AccountSession;
|
import net.runelite.client.account.AccountSession;
|
||||||
import net.runelite.client.account.SessionManager;
|
import net.runelite.client.account.SessionManager;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.events.SessionClose;
|
import net.runelite.client.events.SessionClose;
|
||||||
@@ -178,6 +179,9 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private RuneLiteConfig runeLiteConfig;
|
||||||
|
|
||||||
private Widget grandExchangeText;
|
private Widget grandExchangeText;
|
||||||
private Widget grandExchangeItem;
|
private Widget grandExchangeItem;
|
||||||
private String grandExchangeExamine;
|
private String grandExchangeExamine;
|
||||||
@@ -877,12 +881,14 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
geText.setText(text);
|
geText.setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void openGeLink(String name, int itemId)
|
void openGeLink(String name, int itemId)
|
||||||
{
|
{
|
||||||
final String url = "https://services.runescape.com/m=itemdb_oldschool/"
|
final String url = runeLiteConfig.useWikiItemPrices() ?
|
||||||
+ name.replaceAll(" ", "+")
|
"https://prices.runescape.wiki/osrs/item/" + itemId :
|
||||||
+ "/viewitem?obj="
|
"https://services.runescape.com/m=itemdb_oldschool/"
|
||||||
+ itemId;
|
+ name.replaceAll(" ", "+")
|
||||||
|
+ "/viewitem?obj="
|
||||||
|
+ itemId;
|
||||||
LinkBrowser.browse(url);
|
LinkBrowser.browse(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
private final ItemManager itemManager;
|
private final ItemManager itemManager;
|
||||||
private final ScheduledExecutorService executor;
|
private final ScheduledExecutorService executor;
|
||||||
private final RuneLiteConfig runeLiteConfig;
|
private final RuneLiteConfig runeLiteConfig;
|
||||||
|
private final GrandExchangePlugin grandExchangePlugin;
|
||||||
|
|
||||||
private final IconTextField searchBar = new IconTextField();
|
private final IconTextField searchBar = new IconTextField();
|
||||||
|
|
||||||
@@ -83,12 +84,13 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private GrandExchangeSearchPanel(ClientThread clientThread, ItemManager itemManager,
|
private GrandExchangeSearchPanel(ClientThread clientThread, ItemManager itemManager,
|
||||||
ScheduledExecutorService executor, RuneLiteConfig runeLiteConfig)
|
ScheduledExecutorService executor, RuneLiteConfig runeLiteConfig, GrandExchangePlugin grandExchangePlugin)
|
||||||
{
|
{
|
||||||
this.clientThread = clientThread;
|
this.clientThread = clientThread;
|
||||||
this.itemManager = itemManager;
|
this.itemManager = itemManager;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.runeLiteConfig = runeLiteConfig;
|
this.runeLiteConfig = runeLiteConfig;
|
||||||
|
this.grandExchangePlugin = grandExchangePlugin;
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
@@ -215,9 +217,10 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
|
|
||||||
int itemPrice = useActivelyTradedPrice && item.getWikiPrice() > 0 ? item.getWikiPrice() : item.getPrice();
|
int itemPrice = useActivelyTradedPrice && item.getWikiPrice() > 0 ? item.getWikiPrice() : item.getPrice();
|
||||||
int itemLimit = itemStats != null ? itemStats.getGeLimit() : 0;
|
int itemLimit = itemStats != null ? itemStats.getGeLimit() : 0;
|
||||||
|
final int haPrice = itemComp.getHaPrice();
|
||||||
AsyncBufferedImage itemImage = itemManager.getImage(itemId);
|
AsyncBufferedImage itemImage = itemManager.getImage(itemId);
|
||||||
|
|
||||||
itemsList.add(new GrandExchangeItems(itemImage, item.getName(), itemId, itemPrice, itemComp.getPrice() * 0.6, itemLimit));
|
itemsList.add(new GrandExchangeItems(itemImage, item.getName(), itemId, itemPrice, haPrice, itemLimit));
|
||||||
|
|
||||||
// If using hotkey to lookup item, stop after finding match.
|
// If using hotkey to lookup item, stop after finding match.
|
||||||
if (exactMatch && item.getName().equalsIgnoreCase(lookup))
|
if (exactMatch && item.getName().equalsIgnoreCase(lookup))
|
||||||
@@ -231,7 +234,7 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (GrandExchangeItems item : itemsList)
|
for (GrandExchangeItems item : itemsList)
|
||||||
{
|
{
|
||||||
GrandExchangeItemPanel panel = new GrandExchangeItemPanel(item.getIcon(), item.getName(),
|
GrandExchangeItemPanel panel = new GrandExchangeItemPanel(grandExchangePlugin, item.getIcon(), item.getName(),
|
||||||
item.getItemId(), item.getGePrice(), item.getHaPrice(), item.getGeItemLimit());
|
item.getItemId(), item.getGePrice(), item.getHaPrice(), item.getGeItemLimit());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ enum DungeonLocation
|
|||||||
FREMENNIK_SLAYER("Fremennik Slayer Dungeon", new WorldPoint(2796, 3615, 0)),
|
FREMENNIK_SLAYER("Fremennik Slayer Dungeon", new WorldPoint(2796, 3615, 0)),
|
||||||
GOBLIN_CAVE("Goblin Cave", new WorldPoint(2622, 3393, 0)),
|
GOBLIN_CAVE("Goblin Cave", new WorldPoint(2622, 3393, 0)),
|
||||||
GOD_WARS("God Wars Dungeon", new WorldPoint(2917, 3747, 0)),
|
GOD_WARS("God Wars Dungeon", new WorldPoint(2917, 3747, 0)),
|
||||||
GRAND_TREE("Grand Tree Tunnels", new WorldPoint(2464, 3496, 0)),
|
GRAND_TREE("Grand Tree Tunnels", new WorldPoint(2462, 3496, 0)),
|
||||||
GAUNTLET("The Gauntlet", new WorldPoint(3227, 6116, 0)),
|
GAUNTLET("The Gauntlet", new WorldPoint(3227, 6116, 0)),
|
||||||
HAM_HIDEOUT("H.A.M. Hideout", new WorldPoint(3164, 3252, 0)),
|
HAM_HIDEOUT("H.A.M. Hideout", new WorldPoint(3164, 3252, 0)),
|
||||||
HEROES_GUILD("Heroes' Guild mine", new WorldPoint(2891, 3507, 0)),
|
HEROES_GUILD("Heroes' Guild mine", new WorldPoint(2891, 3507, 0)),
|
||||||
@@ -140,6 +140,7 @@ enum DungeonLocation
|
|||||||
RED_CHIN_HUNTING("Red chinchompa hunting ground", new WorldPoint(2525, 2894, 0)),
|
RED_CHIN_HUNTING("Red chinchompa hunting ground", new WorldPoint(2525, 2894, 0)),
|
||||||
REVENANT_CAVES_N("Revenant Caves", new WorldPoint(3124, 3832, 0)),
|
REVENANT_CAVES_N("Revenant Caves", new WorldPoint(3124, 3832, 0)),
|
||||||
REVENANT_CAVES_S("Revenant Caves", new WorldPoint(3074, 3655, 0)),
|
REVENANT_CAVES_S("Revenant Caves", new WorldPoint(3074, 3655, 0)),
|
||||||
|
REVENANT_CAVES_W("Revenant Caves", new WorldPoint(3065, 3740, 0)),
|
||||||
RIVER_ELID("River Elid Dungeon", new WorldPoint(3370, 3132, 0)),
|
RIVER_ELID("River Elid Dungeon", new WorldPoint(3370, 3132, 0)),
|
||||||
RIVER_KELDA("River Kelda", new WorldPoint(2835, 10112, 0)),
|
RIVER_KELDA("River Kelda", new WorldPoint(2835, 10112, 0)),
|
||||||
SALT_MINE("Salt Mine", new WorldPoint(2866, 3941, 0)),
|
SALT_MINE("Salt Mine", new WorldPoint(2866, 3941, 0)),
|
||||||
|
|||||||
@@ -199,6 +199,10 @@ enum RareTreeLocation
|
|||||||
// Feldip Hills
|
// Feldip Hills
|
||||||
new WorldPoint(2476, 2893, 0)),
|
new WorldPoint(2476, 2893, 0)),
|
||||||
|
|
||||||
|
BLISTERWOOD("Blisterwood tree", 62,
|
||||||
|
// Darkmeyer
|
||||||
|
new WorldPoint(3631, 3362, 0)),
|
||||||
|
|
||||||
SULLIUSCEP("Sulliuscep", 65,
|
SULLIUSCEP("Sulliuscep", 65,
|
||||||
// Fossil Island
|
// Fossil Island
|
||||||
new WorldPoint(3662, 3802, 0),
|
new WorldPoint(3662, 3802, 0),
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class ChatNotificationsPluginTest
|
|||||||
public void before()
|
public void before()
|
||||||
{
|
{
|
||||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||||
|
when(config.highlightRegexString()).thenReturn("");
|
||||||
|
when(config.highlightWordsString()).thenReturn("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -102,6 +104,42 @@ public class ChatNotificationsPluginTest
|
|||||||
verify(messageNode).setValue("<colHIGHLIGHT>Deathbeam<colNORMAL>, <colHIGHLIGHT>Deathbeam<colNORMAL> OSRS");
|
verify(messageNode).setValue("<colHIGHLIGHT>Deathbeam<colNORMAL>, <colHIGHLIGHT>Deathbeam<colNORMAL> OSRS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRegexMultiplePatternsMessage()
|
||||||
|
{
|
||||||
|
when(config.highlightRegexString()).thenReturn("brandie+\ntest");
|
||||||
|
|
||||||
|
MessageNode messageNode = mock(MessageNode.class);
|
||||||
|
when(messageNode.getValue()).thenReturn("brandieeee testing");
|
||||||
|
|
||||||
|
ChatMessage chatMessage = new ChatMessage();
|
||||||
|
chatMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||||
|
chatMessage.setMessageNode(messageNode);
|
||||||
|
|
||||||
|
chatNotificationsPlugin.startUp();
|
||||||
|
chatNotificationsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
|
verify(messageNode).setValue("<colHIGHLIGHT>brandieeee<colNORMAL> <colHIGHLIGHT>test<colNORMAL>ing");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRegexMultiplePatternsWithOnlyOneMatch()
|
||||||
|
{
|
||||||
|
when(config.highlightRegexString()).thenReturn("brandie+\nwillNotMatch");
|
||||||
|
|
||||||
|
MessageNode messageNode = mock(MessageNode.class);
|
||||||
|
when(messageNode.getValue()).thenReturn("brandieeee testing");
|
||||||
|
|
||||||
|
ChatMessage chatMessage = new ChatMessage();
|
||||||
|
chatMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||||
|
chatMessage.setMessageNode(messageNode);
|
||||||
|
|
||||||
|
chatNotificationsPlugin.startUp();
|
||||||
|
chatNotificationsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
|
verify(messageNode).setValue("<colHIGHLIGHT>brandieeee<colNORMAL> testing");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLtGt()
|
public void testLtGt()
|
||||||
{
|
{
|
||||||
@@ -179,7 +217,7 @@ public class ChatNotificationsPluginTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreceedingColor()
|
public void testPrecedingColor()
|
||||||
{
|
{
|
||||||
when(config.highlightWordsString()).thenReturn("you. It");
|
when(config.highlightWordsString()).thenReturn("you. It");
|
||||||
|
|
||||||
@@ -239,10 +277,10 @@ public class ChatNotificationsPluginTest
|
|||||||
public void highlightListTest()
|
public void highlightListTest()
|
||||||
{
|
{
|
||||||
when(config.highlightWordsString()).thenReturn("this,is, a , test, ");
|
when(config.highlightWordsString()).thenReturn("this,is, a , test, ");
|
||||||
final List<String> higlights = Text.fromCSV(config.highlightWordsString());
|
final List<String> highlights = Text.fromCSV(config.highlightWordsString());
|
||||||
assertEquals(4, higlights.size());
|
assertEquals(4, highlights.size());
|
||||||
|
|
||||||
final Iterator<String> iterator = higlights.iterator();
|
final Iterator<String> iterator = highlights.iterator();
|
||||||
assertEquals("this", iterator.next());
|
assertEquals("this", iterator.next());
|
||||||
assertEquals("is", iterator.next());
|
assertEquals("is", iterator.next());
|
||||||
assertEquals("a", iterator.next());
|
assertEquals("a", iterator.next());
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
package net.runelite.client.plugins.grandexchange;public class GrandExchangeOfferSlotTest {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user