diff --git a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java index fb42585520..1a97b5ea6c 100644 --- a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java +++ b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java @@ -446,8 +446,8 @@ public class Hooks implements Callbacks try { - renderer.render(graphics2d, OverlayLayer.ABOVE_WIDGETS); renderer.render(graphics2d, OverlayLayer.ABOVE_MAP); + renderer.render(graphics2d, OverlayLayer.ABOVE_WIDGETS); } catch (Exception ex) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java index 5fd3a87fcc..b2a0a51ed3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java @@ -25,6 +25,7 @@ */ package net.runelite.client.plugins.chatnotifications; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.inject.Provides; @@ -151,7 +152,7 @@ public class ChatNotificationsPlugin extends Plugin List items = Text.fromCSV(this.highlightWordsString); String joined = items.stream() .map(Text::escapeJagex) // we compare these strings to the raw Jagex ones - .map(Pattern::quote) + .map(this::quoteAndIgnoreColor) // regex escape and ignore nested colors in the target message .collect(Collectors.joining("|")); // To match \b doesn't work due to <> not being in \w, // so match \b or \s @@ -232,7 +233,26 @@ public class ChatNotificationsPlugin extends Plugin while (matcher.find()) { String value = matcher.group(); - matcher.appendReplacement(stringBuffer, "" + value + ""); + + // Determine the ending color by: + // 1) use the color from value if it has one + // 2) use the last color from stringBuffer + + // To do #2 we just search for the last col tag after calling appendReplacement + String endColor = getLastColor(value); + + // Strip color tags from the highlighted region so that it remains highlighted correctly + value = stripColor(value); + + matcher.appendReplacement(stringBuffer, "' + value); + + if (endColor == null) + { + endColor = getLastColor(stringBuffer.toString()); + } + + // Append end color + stringBuffer.append(endColor == null ? "" : endColor); + update = true; found = true; } @@ -292,4 +312,61 @@ public class ChatNotificationsPlugin extends Plugin this.notifyOnDuel = config.notifyOnDuel(); this.notifyOnPm = config.notifyOnPm(); } + + private String quoteAndIgnoreColor(String str) + { + StringBuilder stringBuilder = new StringBuilder(); + + for (int i = 0; i < str.length(); ++i) + { + char c = str.charAt(i); + stringBuilder.append(Pattern.quote(String.valueOf(c))); + stringBuilder.append("(?:]*?>)?"); + } + + return stringBuilder.toString(); + } + + /** + * Get the last color tag from a string, or null if there was none + * + * @param str + * @return + */ + private static String getLastColor(String str) + { + int colIdx = str.lastIndexOf(""); + + if (colEndIdx > colIdx) + { + // ends in a which resets the color to normal + return ""; + } + + if (colIdx == -1) + { + return null; // no color + } + + int closeIdx = str.indexOf('>', colIdx); + if (closeIdx == -1) + { + return null; // unclosed col tag + } + + return str.substring(colIdx, closeIdx + 1); // include the > + } + + /** + * Strip color tags from a string. + * + * @param str + * @return + */ + @VisibleForTesting + static String stripColor(String str) + { + return str.replaceAll("(|)", ""); + } } 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 23b7baf567..ed6522ceba 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 @@ -115,6 +115,13 @@ public class ClueScrollPlugin extends Plugin private static final Color HIGHLIGHT_BORDER_COLOR = Color.ORANGE; private static final Color HIGHLIGHT_HOVER_BORDER_COLOR = HIGHLIGHT_BORDER_COLOR.darker(); private static final Color HIGHLIGHT_FILL_COLOR = new Color(0, 255, 0, 20); + private static final int[] REGION_MIRRORS = { + // Prifddinas + 12894, 8755, + 12895, 8756, + 13150, 9011, + 13151, 9012 + }; @Getter private ClueScroll clue; @@ -386,12 +393,13 @@ public class ClueScrollPlugin extends Plugin if (clue instanceof LocationClueScroll) { - final WorldPoint location = ((LocationClueScroll) clue).getLocation(); + final WorldPoint[] locations = ((LocationClueScroll) clue).getLocations(); - if (location != null) + for (WorldPoint location : locations) { // Only set the location hint arrow if we do not already have more accurate location - if (this.displayHintArrows + if (location.isInScene(client) + && this.displayHintArrows && (client.getHintArrowNpc() == null || !npcsToMark.contains(client.getHintArrowNpc()))) { @@ -618,7 +626,11 @@ public class ClueScrollPlugin extends Plugin minX *= -1; } - return new CoordinateClue(text, coordinatesToWorldPoint(degX, minX, degY, minY)); + WorldPoint coordinate = coordinatesToWorldPoint(degX, minX, degY, minY); + // Convert from overworld to real + WorldPoint mirrorPoint = getMirrorPoint(coordinate, false); + // Use mirror point as mirrorLocation if there is one + return new CoordinateClue(text, coordinate, coordinate == mirrorPoint ? null : mirrorPoint); } /** @@ -820,4 +832,29 @@ public class ClueScrollPlugin extends Plugin newScroll ); } + + /** + * Translate a coordinate either between overworld and real, or real and overworld + * + * @param worldPoint + * @param toOverworld whether to convert to overworld coordinates, or to real coordinates + * @return + */ + public static WorldPoint getMirrorPoint(WorldPoint worldPoint, boolean toOverworld) + { + int region = worldPoint.getRegionID(); + for (int i = 0; i < REGION_MIRRORS.length; i += 2) + { + int real = REGION_MIRRORS[i]; + int overworld = REGION_MIRRORS[i + 1]; + + // Test against what we are converting from + if (region == (toOverworld ? real : overworld)) + { + return WorldPoint.fromRegion(toOverworld ? overworld : real, + worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane()); + } + } + return worldPoint; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java index 2fb7891866..268e03f5a0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.cluescrolls.clues; import com.google.common.collect.ImmutableMap; import java.awt.Color; import java.awt.Graphics2D; +import javax.annotation.Nullable; import lombok.Getter; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; @@ -198,14 +199,33 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati private final String text; private final WorldPoint location; + /** + * For regions which are mirrored, the location of the the clue in the mirrored region. + */ + @Nullable + private final WorldPoint mirrorLocation; - public CoordinateClue(String text, WorldPoint location) + public CoordinateClue(String text, WorldPoint location, WorldPoint mirrorLocation) { this.text = text; this.location = location; + this.mirrorLocation = mirrorLocation; setRequiresSpade(true); } + @Override + public WorldPoint[] getLocations() + { + if (mirrorLocation != null) + { + return new WorldPoint[]{location, mirrorLocation}; + } + else + { + return new WorldPoint[]{location}; + } + } + @Override public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plugin) { @@ -229,13 +249,14 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati @Override public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin) { - LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation()); - - if (localLocation == null) + for (WorldPoint worldPoint : getLocations()) { - return; - } + LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), worldPoint); - OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE); + if (localLocation != null) + { + OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE); + } + } } } 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 b63ad9d21e..f88a428caa 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 @@ -292,7 +292,8 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat return false; } - final WorldPoint localWorld = plugin.getClient().getLocalPlayer().getWorldLocation(); + // Convert from real to overworld + final WorldPoint localWorld = ClueScrollPlugin.getMirrorPoint(plugin.getClient().getLocalPlayer().getWorldLocation(), true); if (localWorld == null) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/LocationClueScroll.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/LocationClueScroll.java index 323e0a498e..194aefcb5a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/LocationClueScroll.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/LocationClueScroll.java @@ -29,4 +29,10 @@ import net.runelite.api.coords.WorldPoint; public interface LocationClueScroll { WorldPoint getLocation(); + + default WorldPoint[] getLocations() + { + WorldPoint location = getLocation(); + return location == null ? new WorldPoint[0] : new WorldPoint[]{location}; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java index f98ee1639e..268f7784ff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java @@ -67,6 +67,7 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.TooltipManager; @@ -106,7 +107,8 @@ class DevToolsOverlay extends Overlay private DevToolsOverlay(Client client, DevToolsPlugin plugin, TooltipManager toolTipManager) { setPosition(OverlayPosition.DYNAMIC); - setLayer(OverlayLayer.ABOVE_MAP); + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGHEST); this.client = client; this.plugin = plugin; this.toolTipManager = toolTipManager; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssMinimapOverlay.java new file mode 100644 index 0000000000..a1952b3372 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssMinimapOverlay.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2019 Hydrox6 + * 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.runecraft; + +import com.google.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.DecorativeObject; +import net.runelite.api.Perspective; +import net.runelite.api.Point; +import net.runelite.client.game.ItemManager; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.util.HashMap; +import java.util.Map; + +class AbyssMinimapOverlay extends Overlay +{ + private static final Dimension IMAGE_SIZE = new Dimension(15, 14); + + private final Map abyssIcons = new HashMap<>(); + private final Client client; + private final RunecraftPlugin plugin; + private final ItemManager itemManager; + + @Inject + AbyssMinimapOverlay(Client client, RunecraftPlugin plugin, ItemManager itemManager) + { + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_WIDGETS); + this.client = client; + this.plugin = plugin; + this.itemManager = itemManager; + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (!plugin.isShowRifts()) + { + return null; + } + + for (DecorativeObject object : plugin.getAbyssObjects()) + { + AbyssRifts rift = AbyssRifts.getRift(object.getId()); + if (rift == null || !plugin.getRifts().contains(rift)) + { + continue; + } + + BufferedImage image = getImage(rift); + Point miniMapImage = Perspective.getMiniMapImageLocation(client, object.getLocalLocation(), image); + + if (miniMapImage != null) + { + graphics.drawImage(image, miniMapImage.getX(), miniMapImage.getY(), null); + } + } + + return null; + } + + private BufferedImage getImage(AbyssRifts rift) + { + BufferedImage image = abyssIcons.get(rift); + if (image != null) + { + return image; + } + + // Since item image is too big, we must resize it first. + image = itemManager.getImage(rift.getItemId()); + BufferedImage resizedImage = new BufferedImage(IMAGE_SIZE.width, IMAGE_SIZE.height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = resizedImage.createGraphics(); + g.drawImage(image, 0, 0, IMAGE_SIZE.width, IMAGE_SIZE.height, null); + g.dispose(); + + abyssIcons.put(rift, resizedImage); + return resizedImage; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java index a6a64fd177..9dd2dd5e8d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java @@ -31,30 +31,10 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import java.awt.geom.Area; -import java.awt.image.BufferedImage; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; import net.runelite.api.Client; import net.runelite.api.DecorativeObject; import net.runelite.api.NPC; -import net.runelite.api.Perspective; import net.runelite.api.Point; -import net.runelite.client.game.ItemManager; -import static net.runelite.client.plugins.runecraft.AbyssRifts.AIR_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.BLOOD_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.BODY_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.CHAOS_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.COSMIC_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.DEATH_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.EARTH_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.FIRE_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.LAW_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.MIND_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.NATURE_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.SOUL_RIFT; -import static net.runelite.client.plugins.runecraft.AbyssRifts.WATER_RIFT; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @@ -63,17 +43,9 @@ import net.runelite.client.ui.overlay.OverlayUtil; @Singleton class AbyssOverlay extends Overlay { - private static final Dimension IMAGE_SIZE = new Dimension(15, 14); - - private final Set rifts = new HashSet<>(); - private final Map abyssIcons = new HashMap<>(); - private final Client client; private final RunecraftPlugin plugin; - @Inject - private ItemManager itemManager; - @Inject AbyssOverlay(final Client client, final RunecraftPlugin plugin) { @@ -90,7 +62,7 @@ class AbyssOverlay extends Overlay { for (DecorativeObject object : plugin.getAbyssObjects()) { - renderRifts(graphics, object); + renderRift(graphics, object); } } @@ -124,118 +96,29 @@ class AbyssOverlay extends Overlay OverlayUtil.renderPolygon(graphics, tilePoly, Color.green); } - private void renderRifts(Graphics2D graphics, DecorativeObject object) + private void renderRift(Graphics2D graphics, DecorativeObject object) { AbyssRifts rift = AbyssRifts.getRift(object.getId()); - if (rift == null || !rifts.contains(rift)) + if (rift == null || !plugin.getRifts().contains(rift)) { return; } - if (plugin.isShowClickBox()) + Point mousePosition = client.getMouseCanvasPosition(); + Area objectClickbox = object.getClickbox(); + if (objectClickbox != null) { - //Draw clickbox - Point mousePosition = client.getMouseCanvasPosition(); - Area objectClickbox = object.getClickbox(); - if (objectClickbox != null) + if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) { - if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) - { - graphics.setColor(Color.MAGENTA.darker()); - } - else - { - graphics.setColor(Color.MAGENTA); - } - graphics.draw(objectClickbox); - graphics.setColor(new Color(255, 0, 255, 20)); - graphics.fill(objectClickbox); + graphics.setColor(Color.MAGENTA.darker()); } - } - - //Draw minimap - BufferedImage image = getImage(rift); - Point miniMapImage = Perspective.getMiniMapImageLocation(client, object.getLocalLocation(), image); - - if (miniMapImage != null) - { - graphics.drawImage(image, miniMapImage.getX(), miniMapImage.getY(), null); + else + { + graphics.setColor(Color.MAGENTA); + } + graphics.draw(objectClickbox); + graphics.setColor(new Color(255, 0, 255, 20)); + graphics.fill(objectClickbox); } } - - private BufferedImage getImage(AbyssRifts rift) - { - BufferedImage image = abyssIcons.get(rift); - if (image != null) - { - return image; - } - - // Since item image is too big, we must resize it first. - image = itemManager.getImage(rift.getItemId()); - BufferedImage resizedImage = new BufferedImage(IMAGE_SIZE.width, IMAGE_SIZE.height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = resizedImage.createGraphics(); - g.drawImage(image, 0, 0, IMAGE_SIZE.width, IMAGE_SIZE.height, null); - g.dispose(); - - abyssIcons.put(rift, resizedImage); - return resizedImage; - } - - public void updateConfig() - { - rifts.clear(); - if (plugin.isShowAir()) - { - rifts.add(AIR_RIFT); - } - if (plugin.isShowBlood()) - { - rifts.add(BLOOD_RIFT); - } - if (plugin.isShowBody()) - { - rifts.add(BODY_RIFT); - } - if (plugin.isShowChaos()) - { - rifts.add(CHAOS_RIFT); - } - if (plugin.isShowCosmic()) - { - rifts.add(COSMIC_RIFT); - } - if (plugin.isShowDeath()) - { - rifts.add(DEATH_RIFT); - } - if (plugin.isShowEarth()) - { - rifts.add(EARTH_RIFT); - } - if (plugin.isShowFire()) - { - rifts.add(FIRE_RIFT); - } - if (plugin.isShowLaw()) - { - rifts.add(LAW_RIFT); - } - if (plugin.isShowMind()) - { - rifts.add(MIND_RIFT); - } - if (plugin.isShowNature()) - { - rifts.add(NATURE_RIFT); - } - if (plugin.isShowSoul()) - { - rifts.add(SOUL_RIFT); - } - if (plugin.isShowWater()) - { - rifts.add(WATER_RIFT); - } - } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftPlugin.java index 9d816612f3..66c093576a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftPlugin.java @@ -61,6 +61,7 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.menuentryswapper.BankComparableEntry; import net.runelite.client.plugins.menuentryswapper.EquipmentComparableEntry; +import static net.runelite.client.plugins.runecraft.AbyssRifts.*; import net.runelite.client.ui.overlay.OverlayManager; @@ -88,6 +89,8 @@ public class RunecraftPlugin extends Plugin ItemID.LARGE_POUCH_5513, ItemID.GIANT_POUCH_5515 ); + private final Set rifts = new HashSet<>(); + @Inject @Getter(AccessLevel.NONE) private Client client; @@ -99,6 +102,9 @@ public class RunecraftPlugin extends Plugin private AbyssOverlay abyssOverlay; @Inject @Getter(AccessLevel.NONE) + private AbyssMinimapOverlay abyssMinimapOverlay; + @Inject + @Getter(AccessLevel.NONE) private RunecraftOverlay runecraftOverlay; @Inject @Getter(AccessLevel.NONE) @@ -147,8 +153,8 @@ public class RunecraftPlugin extends Plugin { updateConfig(); addSubscriptions(); - abyssOverlay.updateConfig(); overlayManager.add(abyssOverlay); + overlayManager.add(abyssMinimapOverlay); overlayManager.add(runecraftOverlay); handleSwaps(); } @@ -161,6 +167,7 @@ public class RunecraftPlugin extends Plugin darkMage = null; degradedPouchInInventory = false; overlayManager.remove(abyssOverlay); + overlayManager.remove(abyssMinimapOverlay); overlayManager.remove(runecraftOverlay); removeSwaps(); } @@ -185,7 +192,6 @@ public class RunecraftPlugin extends Plugin } updateConfig(); - abyssOverlay.updateConfig(); if (event.getKey().equals("essPouch") || event.getKey().equals("Lavas")) { @@ -350,5 +356,64 @@ public class RunecraftPlugin extends Plugin this.showSoul = config.showSoul(); this.showWater = config.showWater(); this.showClickBox = config.showClickBox(); + + updateRifts(); } -} + + private void updateRifts() + { + rifts.clear(); + if (config.showAir()) + { + rifts.add(AIR_RIFT); + } + if (config.showBlood()) + { + rifts.add(BLOOD_RIFT); + } + if (config.showBody()) + { + rifts.add(BODY_RIFT); + } + if (config.showChaos()) + { + rifts.add(CHAOS_RIFT); + } + if (config.showCosmic()) + { + rifts.add(COSMIC_RIFT); + } + if (config.showDeath()) + { + rifts.add(DEATH_RIFT); + } + if (config.showEarth()) + { + rifts.add(EARTH_RIFT); + } + if (config.showFire()) + { + rifts.add(FIRE_RIFT); + } + if (config.showLaw()) + { + rifts.add(LAW_RIFT); + } + if (config.showMind()) + { + rifts.add(MIND_RIFT); + } + if (config.showNature()) + { + rifts.add(NATURE_RIFT); + } + if (config.showSoul()) + { + rifts.add(SOUL_RIFT); + } + if (config.showWater()) + { + rifts.add(WATER_RIFT); + } + } +} \ No newline at end of file diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java index c0d0823974..9cacb827af 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java @@ -98,6 +98,82 @@ public class ChatNotificationsPluginTest verify(messageNode).setValue("Deathbeam, Deathbeam OSRS"); } + @Test + public void testColor() + { + when(config.highlightWordsString()).thenReturn("you. It"); + + String message = "Your dodgy necklace protects you. It has 1 charge left."; + MessageNode messageNode = mock(MessageNode.class); + when(messageNode.getValue()).thenReturn(message); + + ChatMessage chatMessage = new ChatMessage(); + chatMessage.setType(ChatMessageType.PUBLICCHAT); + chatMessage.setMessageNode(messageNode); + + chatNotificationsPlugin.startUp(); // load highlight config + chatNotificationsPlugin.onChatMessage(chatMessage); + + verify(messageNode).setValue("Your dodgy necklace protects you. It has 1 charge left."); + } + + @Test + public void testPreceedingColor() + { + when(config.highlightWordsString()).thenReturn("you. It"); + + String message = "Your dodgy necklace protects you. It has 1 charge left."; + MessageNode messageNode = mock(MessageNode.class); + when(messageNode.getValue()).thenReturn(message); + + ChatMessage chatMessage = new ChatMessage(); + chatMessage.setType(ChatMessageType.PUBLICCHAT); + chatMessage.setMessageNode(messageNode); + + chatNotificationsPlugin.startUp(); // load highlight config + chatNotificationsPlugin.onChatMessage(chatMessage); + + verify(messageNode).setValue("Your dodgy necklace protects you. It has 1 charge left."); + } + + @Test + public void testEmoji() + { + when(config.highlightWordsString()).thenReturn("test"); + + String message = "emoji test "; + MessageNode messageNode = mock(MessageNode.class); + when(messageNode.getValue()).thenReturn(message); + + ChatMessage chatMessage = new ChatMessage(); + chatMessage.setType(ChatMessageType.PUBLICCHAT); + chatMessage.setMessageNode(messageNode); + + chatNotificationsPlugin.startUp(); // load highlight config + chatNotificationsPlugin.onChatMessage(chatMessage); + + verify(messageNode).setValue("emoji test "); + } + + @Test + public void testNonMatchedColors() + { + when(config.highlightWordsString()).thenReturn("test"); + + String message = "color test "; + MessageNode messageNode = mock(MessageNode.class); + when(messageNode.getValue()).thenReturn(message); + + ChatMessage chatMessage = new ChatMessage(); + chatMessage.setType(ChatMessageType.PUBLICCHAT); + chatMessage.setMessageNode(messageNode); + + chatNotificationsPlugin.startUp(); // load highlight config + chatNotificationsPlugin.onChatMessage(chatMessage); + + verify(messageNode).setValue("color test "); + } + @Test public void highlightListTest() { @@ -111,4 +187,10 @@ public class ChatNotificationsPluginTest assertEquals("a", iterator.next()); assertEquals("test", iterator.next()); } + + @Test + public void testStripColor() + { + assertEquals("you. It", ChatNotificationsPlugin.stripColor("you. It")); + } } \ No newline at end of file diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/ClueScrollPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/ClueScrollPluginTest.java new file mode 100644 index 0000000000..d1585382d4 --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/ClueScrollPluginTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019 Hydrox6 + * Copyright (c) 2019 Adam + * 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; + +import net.runelite.api.coords.WorldPoint; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import org.junit.Test; + +public class ClueScrollPluginTest +{ + @Test + public void getGetMirrorPoint() + { + WorldPoint point, converted; + + // Zalcano's entrance portal + point = new WorldPoint(3282, 6058, 0); + converted = ClueScrollPlugin.getMirrorPoint(point, true); + assertNotEquals(point, converted); + + // Elven Crystal Chest, which is upstairs + point = new WorldPoint(3273, 6082, 2); + converted = ClueScrollPlugin.getMirrorPoint(point, true); + assertNotEquals(point, converted); + + // Around the area of the Elite coordinate clue + point = new WorldPoint(2185, 3280, 0); + // To overworld + converted = ClueScrollPlugin.getMirrorPoint(point, true); + assertEquals(point, converted); + // To real + converted = ClueScrollPlugin.getMirrorPoint(point, false); + assertNotEquals(point, converted); + + // Brugsen Bursen, Grand Exchange + point = new WorldPoint(3165, 3477, 0); + converted = ClueScrollPlugin.getMirrorPoint(point, false); + assertEquals(point, converted); + } +} \ No newline at end of file diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClueTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClueTest.java index 6896928b29..d3854d843f 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClueTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClueTest.java @@ -33,6 +33,6 @@ public class CoordinateClueTest public void testDuplicateCoordinates() { // If this doesn't throw then the clues map doesn't have duplicate keys - new CoordinateClue("test", new WorldPoint(0, 0, 0)); + new CoordinateClue("test", new WorldPoint(0, 0, 0), null); } } \ No newline at end of file