From bf9a019c2f256fcd41ca58baa79e8d5cee8d06c9 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 11 May 2018 19:37:33 +0200 Subject: [PATCH 1/4] Merge clearMapPoint with resetClue - Move logic from clearMapPoint to resetClue - Call resetClue on plugin shutdown Signed-off-by: Tomas Slusny --- .../plugins/cluescrolls/ClueScrollPlugin.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index 365338bc52..588aa5b9a9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -173,15 +173,10 @@ public class ClueScrollPlugin extends Plugin return configManager.getConfig(ClueScrollConfig.class); } - @Override - protected void startUp() throws Exception - { - } - @Override protected void shutDown() throws Exception { - clearMapPoint(); + resetClue(); } @Override @@ -437,7 +432,11 @@ public class ClueScrollPlugin extends Plugin clueItemChanged = false; clue = null; - clearMapPoint(); + if (worldMapPoint != null) + { + worldMapPointManager.remove(worldMapPoint); + worldMapPoint = null; + } if (config.displayHintArrows()) { @@ -602,13 +601,4 @@ public class ClueScrollPlugin extends Plugin } worldMapPoint.setWorldPoint(point); } - - private void clearMapPoint() - { - if (worldMapPoint != null) - { - worldMapPointManager.remove(worldMapPoint); - worldMapPoint = null; - } - } } From 37703ef8b633f6545b0d13d616fdaa4660abfd96 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 11 May 2018 19:39:34 +0200 Subject: [PATCH 2/4] Improve performance of ClueScrollWorldMapPoint - Create the buffered image only once and not every time ClueScrollWorldMapPoint is created - Pass the world point directly to clue world map point constructor and do it only once Signed-off-by: Tomas Slusny --- .../plugins/cluescrolls/ClueScrollPlugin.java | 3 +- .../cluescrolls/ClueScrollWorldMapPoint.java | 40 ++++++++++--------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index 588aa5b9a9..2d5f35643e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -596,9 +596,8 @@ public class ClueScrollPlugin extends Plugin { if (worldMapPoint == null) { - worldMapPoint = new ClueScrollWorldMapPoint(); + worldMapPoint = new ClueScrollWorldMapPoint(point); worldMapPointManager.add(worldMapPoint); } - worldMapPoint.setWorldPoint(point); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java index 0cc12b4171..62b7891c9c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java @@ -27,44 +27,46 @@ package net.runelite.client.plugins.cluescrolls; import java.awt.Graphics; import java.awt.image.BufferedImage; import net.runelite.api.Point; +import net.runelite.api.coords.WorldPoint; import net.runelite.client.ui.overlay.worldmap.WorldMapPoint; class ClueScrollWorldMapPoint extends WorldMapPoint { - private final BufferedImage worldMapImage; - private final Point imagePoint; - private final BufferedImage edgeSnapImage; + private static final BufferedImage CLUE_SCROLL_WORLD_IMAGE; + private static final Point CLUE_SCROLL_WORLD_IMAGE_POINT; - ClueScrollWorldMapPoint() + static { - super(null, null); + CLUE_SCROLL_WORLD_IMAGE = new BufferedImage(ClueScrollPlugin.MAP_ARROW.getWidth(), ClueScrollPlugin.MAP_ARROW.getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics graphics = CLUE_SCROLL_WORLD_IMAGE.getGraphics(); + graphics.drawImage(ClueScrollPlugin.MAP_ARROW, 0, 0, null); + graphics.drawImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE, 0, 2, null); + CLUE_SCROLL_WORLD_IMAGE_POINT = new Point( + CLUE_SCROLL_WORLD_IMAGE.getWidth() / 2, + CLUE_SCROLL_WORLD_IMAGE.getHeight()); + } + + ClueScrollWorldMapPoint(final WorldPoint worldPoint) + { + super(worldPoint, null); this.setSnapToEdge(true); this.setJumpOnClick(true); - - worldMapImage = new BufferedImage(ClueScrollPlugin.MAP_ARROW.getWidth(), ClueScrollPlugin.MAP_ARROW.getHeight(), BufferedImage.TYPE_INT_ARGB); - Graphics graphics = worldMapImage.getGraphics(); - graphics.drawImage(ClueScrollPlugin.MAP_ARROW, 0, 0, null); - graphics.drawImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE, 0, 2, null); - - imagePoint = new Point(worldMapImage.getWidth() / 2, worldMapImage.getHeight()); - this.setImage(worldMapImage); - this.setImagePoint(imagePoint); - - edgeSnapImage = ClueScrollPlugin.CLUE_SCROLL_IMAGE; + this.setImage(CLUE_SCROLL_WORLD_IMAGE); + this.setImagePoint(CLUE_SCROLL_WORLD_IMAGE_POINT); } @Override public void onEdgeSnap() { - this.setImage(edgeSnapImage); + this.setImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE); this.setImagePoint(null); } @Override public void onEdgeUnsnap() { - this.setImage(worldMapImage); - this.setImagePoint(imagePoint); + this.setImage(CLUE_SCROLL_WORLD_IMAGE); + this.setImagePoint(CLUE_SCROLL_WORLD_IMAGE_POINT); } } From 630474a96e6d0834117a45b7646a9aad9e7bf2b2 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 11 May 2018 19:44:32 +0200 Subject: [PATCH 3/4] Move Hot/Cold message logic to HotColdClue Instead of having giant chunk of logic related to only Hot/Cold clues, move this logic inside the HotColdClue class. Signed-off-by: Tomas Slusny --- .../plugins/cluescrolls/ClueScrollPlugin.java | 47 +--------------- .../cluescrolls/clues/HotColdClue.java | 54 ++++++++++++++++++- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index 2d5f35643e..ae999af2df 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -34,8 +34,6 @@ import java.time.Duration; import java.time.Instant; import java.util.Arrays; import java.util.Collection; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Stream; import javax.imageio.ImageIO; import javax.inject.Inject; @@ -95,10 +93,6 @@ public class ClueScrollPlugin extends Plugin { private static final Duration WAIT_DURATION = Duration.ofMinutes(4); - private static final Pattern INITIAL_STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is (.*)"); - private static final Pattern STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is (.*), (.*) last time\\."); - private static final Pattern FINAL_STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is visibly shaking.*"); - public static final BufferedImage CLUE_SCROLL_IMAGE; public static final BufferedImage MAP_ARROW; public static final BufferedImage EMOTE_IMAGE; @@ -193,46 +187,9 @@ public class ClueScrollPlugin extends Plugin return; } - if (clue instanceof HotColdClue && event.getMessage().startsWith("The device is")) + if (clue instanceof HotColdClue) { - HotColdClue hotColdClue = (HotColdClue) clue; - String message = event.getMessage(); - Matcher m1 = FINAL_STRANGE_DEVICE_MESSAGE.matcher(message); - Matcher m2 = STRANGE_DEVICE_MESSAGE.matcher(message); - Matcher m3 = INITIAL_STRANGE_DEVICE_MESSAGE.matcher(message); - - // the order that these pattern matchers are checked is important - if (m1.find()) - { - // final location for hot cold clue has been found - WorldPoint localWorld = client.getLocalPlayer().getWorldLocation(); - - if (localWorld != null) - { - hotColdClue.markFinalSpot(localWorld); - } - } - else if (m2.find()) - { - String temperature = m2.group(1); - String difference = m2.group(2); - WorldPoint localWorld = client.getLocalPlayer().getWorldLocation(); - - if (localWorld != null) - { - hotColdClue.updatePossibleArea(localWorld, temperature, difference); - } - } - else if (m3.find()) - { - String temperature = m3.group(1); - WorldPoint localWorld = client.getLocalPlayer().getWorldLocation(); - - if (localWorld != null) - { - hotColdClue.updatePossibleArea(localWorld, temperature, ""); - } - } + ((HotColdClue)clue).update(event.getMessage(), this); } if (!event.getMessage().equals("The strange device cools as you find your treasure.") diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java index 001056d8ec..f088b9edc2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java @@ -36,6 +36,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.api.NPC; @@ -58,6 +60,9 @@ import net.runelite.client.ui.overlay.components.TitleComponent; @RequiredArgsConstructor public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueScroll { + private static final Pattern INITIAL_STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is (.*)"); + private static final Pattern STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is (.*), (.*) last time\\."); + private static final Pattern FINAL_STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is visibly shaking.*"); private static final HotColdClue CLUE = new HotColdClue("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Jorral may have a clue.", "Jorral", @@ -235,7 +240,52 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc return null; } - public void updatePossibleArea(WorldPoint currentWp, String temperature, String difference) + public void update(final String message, final ClueScrollPlugin plugin) + { + if (!message.startsWith("The device is")) + { + return; + } + + Matcher m1 = FINAL_STRANGE_DEVICE_MESSAGE.matcher(message); + Matcher m2 = STRANGE_DEVICE_MESSAGE.matcher(message); + Matcher m3 = INITIAL_STRANGE_DEVICE_MESSAGE.matcher(message); + + // the order that these pattern matchers are checked is important + if (m1.find()) + { + // final location for hot cold clue has been found + WorldPoint localWorld = plugin.getClient().getLocalPlayer().getWorldLocation(); + + if (localWorld != null) + { + markFinalSpot(localWorld); + } + } + else if (m2.find()) + { + String temperature = m2.group(1); + String difference = m2.group(2); + WorldPoint localWorld = plugin.getClient().getLocalPlayer().getWorldLocation(); + + if (localWorld != null) + { + updatePossibleArea(localWorld, temperature, difference); + } + } + else if (m3.find()) + { + String temperature = m3.group(1); + WorldPoint localWorld = plugin.getClient().getLocalPlayer().getWorldLocation(); + + if (localWorld != null) + { + updatePossibleArea(localWorld, temperature, ""); + } + } + } + + private void updatePossibleArea(WorldPoint currentWp, String temperature, String difference) { this.location = null; @@ -347,7 +397,7 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc return (firstDistance < secondDistance); } - public void markFinalSpot(WorldPoint wp) + private void markFinalSpot(WorldPoint wp) { this.location = wp; resetHotCold(); From f523d5c5896e23c7dea753f4935f69cc2406b64e Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Wed, 9 May 2018 21:44:42 +0200 Subject: [PATCH 4/4] Add support for map for hot/cold clues - Create new interface for clues that will return multiple locations, have update and reset methods for clues with undetermined location - Implement new LocationsClueScroll and LocationClueScroll to HotColdClue to add support for displaying all the points on world map - Handle the LocationsClueScroll to add each WorldPoint to the world map when found - Add new removeIf method to the WorldMapPointsManager Signed-off-by: Tomas Slusny --- .../plugins/cluescrolls/ClueScrollPlugin.java | 45 +++++++++++-------- .../cluescrolls/clues/HotColdClue.java | 45 +++++++++++-------- .../clues/LocationsClueScroll.java | 38 ++++++++++++++++ .../WorldMapOverlayMouseListener.java | 6 ++- .../worldmap/WorldMapPointManager.java | 6 +++ 5 files changed, 102 insertions(+), 38 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/LocationsClueScroll.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index ae999af2df..c8ea036c76 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -34,6 +34,7 @@ import java.time.Duration; import java.time.Instant; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.stream.Stream; import javax.imageio.ImageIO; import javax.inject.Inject; @@ -76,6 +77,7 @@ import net.runelite.client.plugins.cluescrolls.clues.EmoteClue; import net.runelite.client.plugins.cluescrolls.clues.FairyRingClue; import net.runelite.client.plugins.cluescrolls.clues.HotColdClue; import net.runelite.client.plugins.cluescrolls.clues.LocationClueScroll; +import net.runelite.client.plugins.cluescrolls.clues.LocationsClueScroll; import net.runelite.client.plugins.cluescrolls.clues.MapClue; import net.runelite.client.plugins.cluescrolls.clues.NpcClueScroll; import net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll; @@ -138,10 +140,9 @@ public class ClueScrollPlugin extends Plugin @Inject private WorldMapPointManager worldMapPointManager; - private ClueScrollWorldMapPoint worldMapPoint; - private Integer clueItemId; private boolean clueItemChanged = false; + private boolean worldMapPointsSet = false; static { @@ -187,9 +188,9 @@ public class ClueScrollPlugin extends Plugin return; } - if (clue instanceof HotColdClue) + if (clue instanceof LocationsClueScroll) { - ((HotColdClue)clue).update(event.getMessage(), this); + ((LocationsClueScroll)clue).update(event.getMessage(), this); } if (!event.getMessage().equals("The strange device cools as you find your treasure.") @@ -257,6 +258,12 @@ public class ClueScrollPlugin extends Plugin objectsToMark = null; equippedItems = null; + if (clue instanceof LocationsClueScroll) + { + final List locations = ((LocationsClueScroll) clue).getLocations(); + addMapPoints(locations.toArray(new WorldPoint[locations.size()])); + } + // If we have location clue, set world location before all other types of clues // to allow NPCs and objects to override it when needed if (clue instanceof LocationClueScroll) @@ -268,7 +275,7 @@ public class ClueScrollPlugin extends Plugin client.setHintArrow(location); } - setMapPoint(location); + addMapPoints(location); } if (clue instanceof NpcClueScroll) @@ -288,7 +295,7 @@ public class ClueScrollPlugin extends Plugin client.setHintArrow(npcsToMark[0]); } - setMapPoint(npcsToMark[0].getWorldLocation()); + addMapPoints(npcsToMark[0].getWorldLocation()); } } } @@ -381,19 +388,15 @@ public class ClueScrollPlugin extends Plugin clueItemId = null; } - if (clue instanceof HotColdClue) + if (clue instanceof LocationsClueScroll) { - ((HotColdClue) clue).resetHotCold(); + ((LocationsClueScroll) clue).reset(); } clueItemChanged = false; clue = null; - - if (worldMapPoint != null) - { - worldMapPointManager.remove(worldMapPoint); - worldMapPoint = null; - } + worldMapPointManager.removeIf(point -> point instanceof ClueScrollWorldMapPoint); + worldMapPointsSet = false; if (config.displayHintArrows()) { @@ -549,12 +552,18 @@ public class ClueScrollPlugin extends Plugin return new WorldPoint(x2, y2, 0); } - private void setMapPoint(WorldPoint point) + private void addMapPoints(WorldPoint... points) { - if (worldMapPoint == null) + if (worldMapPointsSet) { - worldMapPoint = new ClueScrollWorldMapPoint(point); - worldMapPointManager.add(worldMapPoint); + return; + } + + worldMapPointsSet = true; + + for (final WorldPoint point : points) + { + worldMapPointManager.add(new ClueScrollWorldMapPoint(point)); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java index f088b9edc2..4325747df7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.cluescrolls.clues; +import com.google.common.collect.Lists; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; @@ -58,7 +59,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent; @Getter @RequiredArgsConstructor -public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueScroll +public class HotColdClue extends ClueScroll implements LocationClueScroll, LocationsClueScroll, TextClueScroll, NpcClueScroll { private static final Pattern INITIAL_STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is (.*)"); private static final Pattern STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is (.*), (.*) last time\\."); @@ -76,6 +77,22 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc private WorldPoint location; private WorldPoint lastWorldPoint; + public static HotColdClue forText(String text) + { + if (CLUE.text.equalsIgnoreCase(text)) + { + return CLUE; + } + + return null; + } + + @Override + public List getLocations() + { + return Lists.transform(digLocations, HotColdLocation::getWorldPoint); + } + @Override public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plugin) { @@ -230,16 +247,7 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc } } - public static HotColdClue forText(String text) - { - if (CLUE.text.equalsIgnoreCase(text)) - { - return CLUE; - } - - return null; - } - + @Override public void update(final String message, final ClueScrollPlugin plugin) { if (!message.startsWith("The device is")) @@ -285,6 +293,13 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc } } + @Override + public void reset() + { + this.lastWorldPoint = null; + digLocations.clear(); + } + private void updatePossibleArea(WorldPoint currentWp, String temperature, String difference) { this.location = null; @@ -400,12 +415,6 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc private void markFinalSpot(WorldPoint wp) { this.location = wp; - resetHotCold(); - } - - public void resetHotCold() - { - this.lastWorldPoint = null; - digLocations.clear(); + reset(); } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/LocationsClueScroll.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/LocationsClueScroll.java new file mode 100644 index 0000000000..8da309171e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/LocationsClueScroll.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Tomas Slusny + * 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.cluescrolls.clues; + +import java.util.List; +import net.runelite.api.coords.WorldPoint; +import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; + +public interface LocationsClueScroll +{ + void update(String message, ClueScrollPlugin plugin); + + void reset(); + + List getLocations(); +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlayMouseListener.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlayMouseListener.java index b86fb7e455..2ef625ff10 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlayMouseListener.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlayMouseListener.java @@ -56,7 +56,8 @@ public class WorldMapOverlayMouseListener extends MouseListener @Override public MouseEvent mousePressed(MouseEvent e) { - List worldMapPoints = worldMapPointManager.getWorldMapPoints(); + final List worldMapPoints = worldMapPointManager.getWorldMapPoints(); + if (SwingUtilities.isLeftMouseButton(e) && !worldMapPoints.isEmpty()) { Point mousePos = clientProvider.get().getMouseCanvasPosition(); @@ -84,7 +85,8 @@ public class WorldMapOverlayMouseListener extends MouseListener @Override public MouseEvent mouseMoved(MouseEvent mouseEvent) { - List worldMapPoints = worldMapPointManager.getWorldMapPoints(); + final List worldMapPoints = worldMapPointManager.getWorldMapPoints(); + if (worldMapPoints.isEmpty()) { return mouseEvent; diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapPointManager.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapPointManager.java index ae836478b9..1f0f5d051b 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapPointManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapPointManager.java @@ -26,6 +26,7 @@ package net.runelite.client.ui.overlay.worldmap; import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; @@ -45,4 +46,9 @@ public class WorldMapPointManager { worldMapPoints.remove(worldMapPoint); } + + public void removeIf(Predicate filter) + { + worldMapPoints.removeIf(filter); + } }