Merge pull request #1571 from Owain94/0909-merge

project: Merge upstream
This commit is contained in:
Kyle
2019-09-09 12:12:02 +01:00
committed by GitHub
13 changed files with 516 additions and 188 deletions

View File

@@ -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)
{

View File

@@ -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<String> 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 <word> \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, "<col" + ChatColorType.HIGHLIGHT + ">" + value + "<col" + ChatColorType.NORMAL + ">");
// Determine the ending color by:
// 1) use the color from value if it has one
// 2) use the last color from stringBuffer + <content between last match and current match>
// 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, "<col" + ChatColorType.HIGHLIGHT + '>' + value);
if (endColor == null)
{
endColor = getLastColor(stringBuffer.toString());
}
// Append end color
stringBuffer.append(endColor == null ? "<col" + ChatColorType.NORMAL + ">" : 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("(?:<col=[^>]*?>)?");
}
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("<col=");
int colEndIdx = str.lastIndexOf("</col>");
if (colEndIdx > colIdx)
{
// ends in a </col> which resets the color to normal
return "<col" + ChatColorType.NORMAL + ">";
}
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("(<col=[0-9a-f]+>|</col>)", "");
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -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)
{

View File

@@ -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};
}
}

View File

@@ -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;

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2019 Hydrox6 <ikada@protonmail.ch>
* 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<AbyssRifts, BufferedImage> 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;
}
}

View File

@@ -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<AbyssRifts> rifts = new HashSet<>();
private final Map<AbyssRifts, BufferedImage> 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);
}
}
}
}

View File

@@ -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;
@@ -70,7 +71,6 @@ import net.runelite.client.ui.overlay.OverlayManager;
tags = {"abyssal", "minimap", "overlay", "rifts", "rc", "runecrafting"}
)
@Singleton
@Getter(AccessLevel.PACKAGE)
public class RunecraftPlugin extends Plugin
{
private static final BankComparableEntry POUCH = new BankComparableEntry("fill", "pouch", false);
@@ -88,52 +88,54 @@ public class RunecraftPlugin extends Plugin
ItemID.LARGE_POUCH_5513,
ItemID.GIANT_POUCH_5515
);
@Getter(AccessLevel.PACKAGE)
private final Set<AbyssRifts> rifts = new HashSet<>();
@Inject
@Getter(AccessLevel.NONE)
private Client client;
@Inject
@Getter(AccessLevel.NONE)
private OverlayManager overlayManager;
@Inject
@Getter(AccessLevel.NONE)
private AbyssOverlay abyssOverlay;
@Inject
private AbyssMinimapOverlay abyssMinimapOverlay;
@Inject
@Getter(AccessLevel.NONE)
private RunecraftOverlay runecraftOverlay;
@Inject
@Getter(AccessLevel.NONE)
private RunecraftConfig config;
@Inject
@Getter(AccessLevel.NONE)
private Notifier notifier;
@Inject
@Getter(AccessLevel.NONE)
private MenuManager menuManager;
@Inject
@Getter(AccessLevel.NONE)
private EventBus eventBus;
@Getter(AccessLevel.PACKAGE)
private final Set<DecorativeObject> abyssObjects = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private boolean degradedPouchInInventory;
@Getter(AccessLevel.PACKAGE)
private boolean degradingNotification;
@Getter(AccessLevel.PACKAGE)
private boolean essPouch;
@Getter(AccessLevel.PACKAGE)
private boolean hightlightDarkMage;
@Getter(AccessLevel.PACKAGE)
private boolean lavas;
private boolean showAir;
private boolean showBlood;
private boolean showBody;
private boolean showChaos;
@Getter(AccessLevel.PACKAGE)
private boolean showClickBox;
private boolean showCosmic;
private boolean showDeath;
private boolean showEarth;
private boolean showFire;
private boolean showLaw;
private boolean showMind;
private boolean showNature;
@Getter(AccessLevel.PACKAGE)
private boolean showRifts;
private boolean showSoul;
private boolean showWater;
@Getter(AccessLevel.PACKAGE)
private NPC darkMage;
@Provides
@@ -147,8 +149,8 @@ public class RunecraftPlugin extends Plugin
{
updateConfig();
addSubscriptions();
abyssOverlay.updateConfig();
overlayManager.add(abyssOverlay);
overlayManager.add(abyssMinimapOverlay);
overlayManager.add(runecraftOverlay);
handleSwaps();
}
@@ -161,6 +163,7 @@ public class RunecraftPlugin extends Plugin
darkMage = null;
degradedPouchInInventory = false;
overlayManager.remove(abyssOverlay);
overlayManager.remove(abyssMinimapOverlay);
overlayManager.remove(runecraftOverlay);
removeSwaps();
}
@@ -185,7 +188,6 @@ public class RunecraftPlugin extends Plugin
}
updateConfig();
abyssOverlay.updateConfig();
if (event.getKey().equals("essPouch") || event.getKey().equals("Lavas"))
{
@@ -336,19 +338,65 @@ public class RunecraftPlugin extends Plugin
this.hightlightDarkMage = config.hightlightDarkMage();
this.degradingNotification = config.degradingNotification();
this.showRifts = config.showRifts();
this.showAir = config.showAir();
this.showBlood = config.showBlood();
this.showBody = config.showBody();
this.showChaos = config.showChaos();
this.showCosmic = config.showCosmic();
this.showDeath = config.showDeath();
this.showEarth = config.showEarth();
this.showFire = config.showFire();
this.showLaw = config.showLaw();
this.showMind = config.showMind();
this.showNature = config.showNature();
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);
}
}
}

View File

@@ -98,6 +98,82 @@ public class ChatNotificationsPluginTest
verify(messageNode).setValue("<colHIGHLIGHT>Deathbeam<colNORMAL>, <colHIGHLIGHT>Deathbeam<colNORMAL> OSRS");
}
@Test
public void testColor()
{
when(config.highlightWordsString()).thenReturn("you. It");
String message = "Your dodgy necklace protects you. <col=ff0000>It has 1 charge left.</col>";
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 <colHIGHLIGHT>you. It<col=ff0000> has 1 charge left.</col>");
}
@Test
public void testPreceedingColor()
{
when(config.highlightWordsString()).thenReturn("you. It");
String message = "Your dodgy <col=00ff00>necklace protects you. It has 1 charge left.</col>";
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 <col=00ff00>necklace protects <colHIGHLIGHT>you. It<col=00ff00> has 1 charge left.</col>");
}
@Test
public void testEmoji()
{
when(config.highlightWordsString()).thenReturn("test");
String message = "emoji test <img=29>";
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 <colHIGHLIGHT>test<colNORMAL> <img=29>");
}
@Test
public void testNonMatchedColors()
{
when(config.highlightWordsString()).thenReturn("test");
String message = "<col=ff0000>color</col> test <img=29>";
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("<col=ff0000>color</col> <colHIGHLIGHT>test<colNORMAL> <img=29>");
}
@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. <col=ff0000>It"));
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2019 Hydrox6 <ikada@protonmail.ch>
* Copyright (c) 2019 Adam <Adam@sigterm.info>
* 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);
}
}

View File

@@ -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);
}
}