From 442c6105ce2f222cefb5cf87abffac93b7044061 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 22 Aug 2021 15:29:11 -0400 Subject: [PATCH 1/5] chat commands: rename tob story mode to entry mode --- .../plugins/chatcommands/ChatCommandsPlugin.java | 13 ++++++++++--- .../chatcommands/ChatCommandsPluginTest.java | 10 +++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 09610e774e..ca2c8bc71a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -392,6 +392,9 @@ public class ChatCommandsPlugin extends Plugin unsetPb(boss); unsetKc(boss.replace(":", ".")); unsetPb(boss.replace(":", ".")); + // Unset old story mode + unsetKc("Theatre of Blood Story Mode"); + unsetPb("Theatre of Blood Story Mode"); } setKc(renamedBoss, kc); @@ -1965,13 +1968,17 @@ public class ChatCommandsPlugin extends Plugin case "raids 2": return "Theatre of Blood"; - case "Theatre of Blood: Story Mode": + case "theatre of blood: story mode": case "tob sm": case "tob story mode": case "tob story": - return "Theatre of Blood Story Mode"; + case "Theatre of Blood: Entry Mode": + case "tob em": + case "tob entry mode": + case "tob entry": + return "Theatre of Blood Entry Mode"; - case "Theatre of Blood: Hard Mode": + case "theatre of blood: hard mode": case "tob cm": case "tob hm": case "tob hard mode": diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java index 77acb81b63..7fa2c8dde5 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java @@ -189,17 +189,17 @@ public class ChatCommandsPluginTest } @Test - public void testTheatreOfBloodStoryMode() + public void testTheatreOfBloodEntryMode() { ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", - "Wave 'The Final Challenge' (Story Mode) complete!
Duration: 2:42
Theatre of Blood wave completion time: 17:00 (new personal best)", null, 0); + "Wave 'The Final Challenge' (Entry Mode) complete!
Duration: 2:42
Theatre of Blood wave completion time: 17:00 (new personal best)", null, 0); chatCommandsPlugin.onChatMessage(chatMessage); - ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood: Story Mode count is: 73.", null, 0); + ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood: Entry Mode count is: 73.", null, 0); chatCommandsPlugin.onChatMessage(chatMessageEvent); - verify(configManager).setRSProfileConfiguration("killcount", "theatre of blood story mode", 73); - verify(configManager).setRSProfileConfiguration("personalbest", "theatre of blood story mode", 17 * 60.); + verify(configManager).setRSProfileConfiguration("killcount", "theatre of blood entry mode", 73); + verify(configManager).setRSProfileConfiguration("personalbest", "theatre of blood entry mode", 17 * 60.); } @Test From ec7af70da4335137e485f9b4f06a65ae1e1c12de Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 22 Aug 2021 14:48:46 -0400 Subject: [PATCH 2/5] npc indicators: allow plugins to specify highlight styles After changing the slayer plugin to use npc indicators for the outline style, some users request being able to set the color of slayer highlights to be unique in order to identify marked npcs such as superiors while slaying. This readds the previous target color config and adds new highlight style options to the slayer plugin. --- .../plugins/npchighlight/HighlightedNpc.java | 45 +++++++++++++ .../npchighlight/NpcIndicatorsPlugin.java | 64 +++++++++++++------ .../npchighlight/NpcIndicatorsService.java | 6 +- .../npchighlight/NpcMinimapOverlay.java | 11 ++-- .../plugins/npchighlight/NpcSceneOverlay.java | 21 +++--- .../client/plugins/slayer/SlayerConfig.java | 46 +++++++++++-- .../client/plugins/slayer/SlayerPlugin.java | 23 ++++++- 7 files changed, 173 insertions(+), 43 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/HighlightedNpc.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/HighlightedNpc.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/HighlightedNpc.java new file mode 100644 index 0000000000..8622b1091f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/HighlightedNpc.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021, 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.npchighlight; + +import java.awt.Color; +import lombok.Builder; +import lombok.Value; +import net.runelite.api.NPC; + +@Value +@Builder +public class HighlightedNpc +{ + NPC npc; + Color highlightColor; + Color fillColor; + boolean hull; + boolean tile; + boolean swTile; + boolean outline; + boolean name; + boolean nameOnMinimap; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 7ebe470d97..02e4926088 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -39,7 +39,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.function.Predicate; +import java.util.function.Function; import javax.inject.Inject; import lombok.AccessLevel; import lombok.Getter; @@ -116,7 +116,7 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService * NPCs to highlight */ @Getter(AccessLevel.PACKAGE) - private final Set highlightedNpcs = new HashSet<>(); + private final Map highlightedNpcs = new HashMap<>(); /** * Dead NPCs that should be displayed with a respawn indicator if the config is on. @@ -175,7 +175,7 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService */ private boolean skipNextSpawnCheck = false; - private final List> higlightPredicates = new ArrayList<>(); + private final List> higlightPredicates = new ArrayList<>(); @Provides NpcIndicatorsConfig provideConfig(ConfigManager configManager) @@ -265,7 +265,7 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService color = config.deadNpcMenuColor(); } - if (color == null && highlightedNpcs.contains(npc) && config.highlightMenuNames() && (!npc.isDead() || !config.ignoreDeadNpcs())) + if (color == null && highlightedNpcs.containsKey(npc) && config.highlightMenuNames() && (!npc.isDead() || !config.ignoreDeadNpcs())) { color = config.highlightColor(); } @@ -365,7 +365,7 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService memorizeNpc(npc); npcTags.add(id); } - highlightedNpcs.add(npc); + highlightedNpcs.put(npc, highlightedNpc(npc)); } } else @@ -391,14 +391,14 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService if (npcTags.contains(npc.getIndex())) { memorizeNpc(npc); - highlightedNpcs.add(npc); + highlightedNpcs.put(npc, highlightedNpc(npc)); spawnedNpcsThisTick.add(npc); return; } if (highlightMatchesNPCName(npcName)) { - highlightedNpcs.add(npc); + highlightedNpcs.put(npc, highlightedNpc(npc)); if (!client.isInInstancedRegion()) { memorizeNpc(npc); @@ -407,11 +407,12 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService return; } - for (Predicate predicate : higlightPredicates) + for (Function predicate : higlightPredicates) { - if (predicate.test(npc)) + HighlightedNpc highlightedNpc = predicate.apply(npc); + if (highlightedNpc != null) { - highlightedNpcs.add(npc); + highlightedNpcs.put(npc, highlightedNpc); if (!client.isInInstancedRegion()) { memorizeNpc(npc); @@ -452,7 +453,18 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService if (npcTags.contains(npc.getIndex()) || highlightMatchesNPCName(npcName)) { - highlightedNpcs.add(npc); + highlightedNpcs.put(npc, highlightedNpc(npc)); + return; + } + + for (Function predicate : higlightPredicates) + { + HighlightedNpc highlightedNpc = predicate.apply(npc); + if (highlightedNpc != null) + { + highlightedNpcs.put(npc, highlightedNpc); + return; + } } } @@ -586,7 +598,7 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService if (npcTags.contains(npc.getIndex())) { - highlightedNpcs.add(npc); + highlightedNpcs.put(npc, highlightedNpc(npc)); continue; } @@ -596,19 +608,20 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService { memorizeNpc(npc); } - highlightedNpcs.add(npc); + highlightedNpcs.put(npc, highlightedNpc(npc)); continue; } - for (Predicate predicate : higlightPredicates) + for (Function predicate : higlightPredicates) { - if (predicate.test(npc)) + HighlightedNpc highlightedNpc = predicate.apply(npc); + if (highlightedNpc != null) { if (!client.isInInstancedRegion()) { memorizeNpc(npc); } - highlightedNpcs.add(npc); + highlightedNpcs.put(npc, highlightedNpc); continue outer; } } @@ -721,14 +734,29 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService teleportGraphicsObjectSpawnedThisTick.clear(); } + private HighlightedNpc highlightedNpc(NPC npc) + { + return HighlightedNpc.builder() + .npc(npc) + .highlightColor(config.highlightColor()) + .fillColor(config.fillColor()) + .hull(config.highlightHull()) + .tile(config.highlightTile()) + .swTile(config.highlightSouthWestTile()) + .outline(config.highlightOutline()) + .name(config.drawNames()) + .nameOnMinimap(config.drawMinimapNames()) + .build(); + } + @Override - public void registerHighlighter(Predicate p) + public void registerHighlighter(Function p) { higlightPredicates.add(p); } @Override - public void unregisterHighlighter(Predicate p) + public void unregisterHighlighter(Function p) { higlightPredicates.remove(p); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsService.java index 43a3b91694..440f33fd65 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsService.java @@ -24,12 +24,12 @@ */ package net.runelite.client.plugins.npchighlight; -import java.util.function.Predicate; +import java.util.function.Function; import net.runelite.api.NPC; public interface NpcIndicatorsService { - void registerHighlighter(Predicate p); - void unregisterHighlighter(Predicate p); + void registerHighlighter(Function p); + void unregisterHighlighter(Function p); void rebuild(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java index 52a17975a7..b8905f93ea 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java @@ -55,16 +55,18 @@ public class NpcMinimapOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - for (NPC npc : plugin.getHighlightedNpcs()) + for (HighlightedNpc highlightedNpc : plugin.getHighlightedNpcs().values()) { - renderNpcOverlay(graphics, npc, Text.removeTags(npc.getName()), config.highlightColor()); + renderNpcOverlay(graphics, highlightedNpc); } return null; } - private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color) + private void renderNpcOverlay(Graphics2D graphics, HighlightedNpc highlightedNpc) { + NPC actor = highlightedNpc.getNpc(); + String name = Text.removeTags(actor.getName()); NPCComposition npcComposition = actor.getTransformedComposition(); if (npcComposition == null || !npcComposition.isInteractible() || (actor.isDead() && config.ignoreDeadNpcs())) @@ -75,9 +77,10 @@ public class NpcMinimapOverlay extends Overlay Point minimapLocation = actor.getMinimapLocation(); if (minimapLocation != null) { + Color color = highlightedNpc.getHighlightColor(); OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color.darker()); - if (config.drawMinimapNames()) + if (highlightedNpc.isNameOnMinimap()) { OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java index 8c2b2b3b06..84e428918c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java @@ -89,9 +89,9 @@ public class NpcSceneOverlay extends Overlay plugin.getDeadNpcsToDisplay().forEach((id, npc) -> renderNpcRespawn(npc, graphics)); } - for (NPC npc : plugin.getHighlightedNpcs()) + for (HighlightedNpc highlightedNpc : plugin.getHighlightedNpcs().values()) { - renderNpcOverlay(graphics, npc); + renderNpcOverlay(graphics, highlightedNpc); } return null; @@ -141,8 +141,9 @@ public class NpcSceneOverlay extends Overlay } } - private void renderNpcOverlay(Graphics2D graphics, NPC actor) + private void renderNpcOverlay(Graphics2D graphics, HighlightedNpc highlightedNpc) { + NPC actor = highlightedNpc.getNpc(); NPCComposition npcComposition = actor.getTransformedComposition(); if (npcComposition == null || !npcComposition.isInteractible() || (actor.isDead() && config.ignoreDeadNpcs())) @@ -150,16 +151,16 @@ public class NpcSceneOverlay extends Overlay return; } - final Color borderColor = config.highlightColor(); - final Color fillColor = config.fillColor(); + final Color borderColor = highlightedNpc.getHighlightColor(); + final Color fillColor = highlightedNpc.getFillColor(); - if (config.highlightHull()) + if (highlightedNpc.isHull()) { Shape objectClickbox = actor.getConvexHull(); renderPoly(graphics, borderColor, fillColor, objectClickbox); } - if (config.highlightTile()) + if (highlightedNpc.isTile()) { int size = npcComposition.getSize(); LocalPoint lp = actor.getLocalLocation(); @@ -168,7 +169,7 @@ public class NpcSceneOverlay extends Overlay renderPoly(graphics, borderColor, fillColor, tilePoly); } - if (config.highlightSouthWestTile()) + if (highlightedNpc.isSwTile()) { int size = npcComposition.getSize(); LocalPoint lp = actor.getLocalLocation(); @@ -181,12 +182,12 @@ public class NpcSceneOverlay extends Overlay renderPoly(graphics, borderColor, fillColor, southWestTilePoly); } - if (config.highlightOutline()) + if (highlightedNpc.isOutline()) { modelOutlineRenderer.drawOutline(actor, (int)config.borderWidth(), borderColor, config.outlineFeather()); } - if (config.drawNames() && actor.getName() != null) + if (highlightedNpc.isName() && actor.getName() != null) { String npcName = Text.removeTags(actor.getName()); Point textLocation = actor.getCanvasTextLocation(graphics, npcName, actor.getLogicalHeight() + 40); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerConfig.java index 258ea51b17..55952cb6d2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerConfig.java @@ -25,6 +25,8 @@ */ package net.runelite.client.plugins.slayer; +import java.awt.Color; +import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @@ -90,17 +92,51 @@ public interface SlayerConfig extends Config @ConfigItem( position = 5, - keyName = "highlightTargets", - name = "Highlight Targets", - description = "Highlight monsters you can kill for your current slayer assignment" + keyName = "highlightHull", + name = "Highlight hull", + description = "Configures whether the NPC hull should be highlighted" ) - default boolean highlightTargets() + default boolean highlightHull() + { + return false; + } + + @ConfigItem( + position = 6, + keyName = "highlightTile", + name = "Highlight tile", + description = "Configures whether the NPC tile should be highlighted" + ) + default boolean highlightTile() { return false; } @ConfigItem( position = 7, + keyName = "highlightOutline", + name = "Highlight outline", + description = "Configures whether or not the NPC outline should be highlighted" + ) + default boolean highlightOutline() + { + return false; + } + + @Alpha + @ConfigItem( + position = 8, + keyName = "targetColor", + name = "Target color", + description = "Color of the highlighted targets" + ) + default Color getTargetColor() + { + return Color.RED; + } + + @ConfigItem( + position = 9, keyName = "weaknessPrompt", name = "Show Monster Weakness", description = "Show an overlay on a monster when it is weak enough to finish off (Only Lizards, Gargoyles & Rockslugs)" @@ -111,7 +147,7 @@ public interface SlayerConfig extends Config } @ConfigItem( - position = 8, + position = 10, keyName = "taskCommand", name = "Task Command", description = "Configures whether the slayer task command is enabled
!task" diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index 729debeb25..6983270fa1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -39,7 +39,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Predicate; +import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; @@ -86,6 +86,7 @@ import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDependency; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.npchighlight.HighlightedNpc; import net.runelite.client.plugins.npchighlight.NpcIndicatorsPlugin; import net.runelite.client.plugins.npchighlight.NpcIndicatorsService; import net.runelite.client.ui.overlay.OverlayManager; @@ -210,7 +211,23 @@ public class SlayerPlugin extends Plugin private boolean loginFlag; private final List targetNames = new ArrayList<>(); - public final Predicate isTarget = (n) -> config.highlightTargets() && targets.contains(n); + public final Function isTarget = (n) -> + { + if ((config.highlightHull() || config.highlightTile() || config.highlightOutline()) && targets.contains(n)) + { + Color color = config.getTargetColor(); + return HighlightedNpc.builder() + .npc(n) + .highlightColor(color) + .fillColor(ColorUtil.colorWithAlpha(color, color.getAlpha() / 12)) + .hull(config.highlightHull()) + .tile(config.highlightTile()) + .outline(config.highlightOutline()) + .build(); + + } + return null; + }; @Override protected void startUp() throws Exception @@ -603,7 +620,7 @@ public class SlayerPlugin extends Plugin } else { - npcIndicatorsService.rebuild(); + clientThread.invoke(npcIndicatorsService::rebuild); } } From e9665f3504968dcf9c4bcf98f2cf027bd65efe59 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 22 Aug 2021 14:49:52 -0400 Subject: [PATCH 3/5] implings plugin: use npc indicators for impling overlay --- .../implings/ImplingMinimapOverlay.java | 82 ------------- .../plugins/implings/ImplingsConfig.java | 8 +- .../plugins/implings/ImplingsOverlay.java | 45 +------- .../plugins/implings/ImplingsPlugin.java | 108 ++++++++---------- .../npchighlight/NpcIndicatorsPluginTest.java | 8 +- 5 files changed, 57 insertions(+), 194 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingMinimapOverlay.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingMinimapOverlay.java deleted file mode 100644 index ab35f9f945..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingMinimapOverlay.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2018, Seth - * 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.implings; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.util.List; -import javax.inject.Inject; -import net.runelite.api.NPC; -import net.runelite.api.Point; -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.OverlayUtil; - -public class ImplingMinimapOverlay extends Overlay -{ - private final ImplingsPlugin plugin; - private final ImplingsConfig config; - - @Inject - private ImplingMinimapOverlay(ImplingsPlugin plugin, ImplingsConfig config) - { - setPosition(OverlayPosition.DYNAMIC); - setLayer(OverlayLayer.ABOVE_WIDGETS); - this.plugin = plugin; - this.config = config; - } - - @Override - public Dimension render(Graphics2D graphics) - { - List imps = plugin.getImplings(); - if (imps.isEmpty()) - { - return null; - } - - for (NPC imp : imps) - { - Point impLocation = imp.getMinimapLocation(); - Color color = plugin.npcToColor(imp); - if (!plugin.showNpc(imp) || impLocation == null || color == null) - { - continue; - } - - OverlayUtil.renderMinimapLocation(graphics, impLocation, color); - - if (config.showName()) - { - Point textLocation = new Point(impLocation.getX() + 1, impLocation.getY()); - OverlayUtil.renderTextLocation(graphics, textLocation, imp.getName(), color); - } - } - - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java index a11ef6f7df..b9f09853a1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java @@ -31,13 +31,11 @@ import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigSection; -/** - * - * @author robin - */ -@ConfigGroup("implings") +@ConfigGroup(ImplingsConfig.GROUP) public interface ImplingsConfig extends Config { + String GROUP = "implings"; + enum ImplingMode { NONE, diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsOverlay.java index 8f58fbe7f2..67472b2e49 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsOverlay.java @@ -28,13 +28,10 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; -import java.util.List; import javax.inject.Inject; -import net.runelite.api.Actor; import net.runelite.api.Client; -import net.runelite.api.NPC; -import net.runelite.api.Point; import net.runelite.api.Perspective; +import net.runelite.api.Point; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; import net.runelite.client.ui.overlay.Overlay; @@ -42,10 +39,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; -/** - * @author robin - */ -public class ImplingsOverlay extends Overlay +class ImplingsOverlay extends Overlay { private final Client client; private final ImplingsConfig config; @@ -64,25 +58,6 @@ public class ImplingsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - List implings = plugin.getImplings(); - - if (implings.isEmpty()) - { - return null; - } - - for (NPC imp : implings) - { - Color color = plugin.npcToColor(imp); - if (!plugin.showNpc(imp) || color == null) - { - continue; - } - - drawImp(graphics, imp, imp.getName(), color); - } - - //Draw static spawns if (config.showSpawn()) { for (ImplingSpawn spawn : ImplingSpawn.values()) @@ -126,20 +101,4 @@ public class ImplingsOverlay extends Overlay OverlayUtil.renderTextLocation(graphics, textPoint, text, color); } } - - private void drawImp(Graphics2D graphics, Actor actor, String text, Color color) - { - Polygon poly = actor.getCanvasTilePoly(); - if (poly != null) - { - OverlayUtil.renderPolygon(graphics, poly, color); - } - - Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight()); - if (textLocation != null) - { - OverlayUtil.renderTextLocation(graphics, textLocation, text, color); - } - } - } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java index f2c25bcbda..6b671ae7d3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java @@ -26,22 +26,22 @@ package net.runelite.client.plugins.implings; import com.google.inject.Provides; import java.awt.Color; -import java.util.ArrayList; -import java.util.List; +import java.util.function.Function; import javax.inject.Inject; -import lombok.AccessLevel; -import lombok.Getter; -import net.runelite.api.GameState; import net.runelite.api.NPC; -import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.NpcChanged; -import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.client.Notifier; +import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDependency; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.npchighlight.HighlightedNpc; +import net.runelite.client.plugins.npchighlight.NpcIndicatorsPlugin; +import net.runelite.client.plugins.npchighlight.NpcIndicatorsService; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( @@ -49,26 +49,45 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Highlight nearby implings on the minimap and on-screen", tags = {"hunter", "minimap", "overlay", "imp"} ) +@PluginDependency(NpcIndicatorsPlugin.class) public class ImplingsPlugin extends Plugin { - @Getter(AccessLevel.PACKAGE) - private final List implings = new ArrayList<>(); - @Inject private OverlayManager overlayManager; @Inject private ImplingsOverlay overlay; - @Inject - private ImplingMinimapOverlay minimapOverlay; - @Inject private ImplingsConfig config; @Inject private Notifier notifier; + @Inject + private NpcIndicatorsService npcIndicatorsService; + + @Inject + private ClientThread clientThread; + + public final Function isTarget = (npc) -> + { + Impling impling = Impling.findImpling(npc.getId()); + if (impling != null && showImpling(impling)) + { + Color color = implingColor(impling); + return HighlightedNpc.builder() + .npc(npc) + .highlightColor(color) + .fillColor(new Color(0, 0, 0, 50)) + .tile(true) + .name(true) + .nameOnMinimap(config.showName()) + .build(); + } + return null; + }; + @Provides ImplingsConfig getConfig(ConfigManager configManager) { @@ -79,15 +98,25 @@ public class ImplingsPlugin extends Plugin protected void startUp() { overlayManager.add(overlay); - overlayManager.add(minimapOverlay); + npcIndicatorsService.registerHighlighter(isTarget); } @Override protected void shutDown() { - implings.clear(); + npcIndicatorsService.unregisterHighlighter(isTarget); overlayManager.remove(overlay); - overlayManager.remove(minimapOverlay); + } + + @Subscribe + private void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals(ImplingsConfig.GROUP)) + { + return; + } + + clientThread.invoke(npcIndicatorsService::rebuild); } @Subscribe @@ -102,8 +131,6 @@ public class ImplingsPlugin extends Plugin { notifier.notify(impling.getImplingType().getName() + " impling is in the area"); } - - implings.add(npc); } } @@ -119,43 +146,11 @@ public class ImplingsPlugin extends Plugin { notifier.notify(impling.getImplingType().getName() + " impling is in the area"); } - - if (!implings.contains(npc)) - { - implings.add(npc); - } } } - @Subscribe - public void onGameStateChanged(GameStateChanged event) + private boolean showImpling(Impling impling) { - if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) - { - implings.clear(); - } - } - - @Subscribe - public void onNpcDespawned(NpcDespawned npcDespawned) - { - if (implings.isEmpty()) - { - return; - } - - NPC npc = npcDespawned.getNpc(); - implings.remove(npc); - } - - boolean showNpc(NPC npc) - { - Impling impling = Impling.findImpling(npc.getId()); - if (impling == null) - { - return false; - } - ImplingsConfig.ImplingMode impMode = showImplingType(impling.getImplingType()); return impMode == ImplingsConfig.ImplingMode.HIGHLIGHT || impMode == ImplingsConfig.ImplingMode.NOTIFY; } @@ -193,17 +188,10 @@ public class ImplingsPlugin extends Plugin } } - Color npcToColor(NPC npc) + private Color implingColor(Impling impling) { - Impling impling = Impling.findImpling(npc.getId()); - if (impling == null) - { - return null; - } - switch (impling.getImplingType()) { - case BABY: return config.getBabyColor(); case YOUNG: @@ -229,7 +217,7 @@ public class ImplingsPlugin extends Plugin case LUCKY: return config.getLuckyColor(); default: - return null; + throw new IllegalArgumentException(); } } } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java index 8fd814b491..8c9c4d4da8 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java @@ -152,12 +152,12 @@ public class NpcIndicatorsPluginTest when(npc.getName()).thenReturn("Joseph"); npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc)); - assertTrue(npcIndicatorsPlugin.getHighlightedNpcs().contains(npc)); + assertTrue(npcIndicatorsPlugin.getHighlightedNpcs().containsKey(npc)); when(npc.getName()).thenReturn("Werewolf"); npcIndicatorsPlugin.onNpcChanged(new NpcChanged(npc, null)); - assertFalse(npcIndicatorsPlugin.getHighlightedNpcs().contains(npc)); + assertFalse(npcIndicatorsPlugin.getHighlightedNpcs().containsKey(npc)); } @Test @@ -171,11 +171,11 @@ public class NpcIndicatorsPluginTest when(npc.getName()).thenReturn("Joseph"); npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc)); - assertFalse(npcIndicatorsPlugin.getHighlightedNpcs().contains(npc)); + assertFalse(npcIndicatorsPlugin.getHighlightedNpcs().containsKey(npc)); when(npc.getName()).thenReturn("Werewolf"); npcIndicatorsPlugin.onNpcChanged(new NpcChanged(npc, null)); - assertTrue(npcIndicatorsPlugin.getHighlightedNpcs().contains(npc)); + assertTrue(npcIndicatorsPlugin.getHighlightedNpcs().containsKey(npc)); } } From c3c1222570f5190aa5f8bf42667335df8d564544 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 23 Aug 2021 16:20:48 -0400 Subject: [PATCH 4/5] chat commands: update to parse new adv log pb counters --- .../chatcommands/ChatCommandsPlugin.java | 58 ++-- .../chatcommands/ChatCommandsPluginTest.java | 306 ++++++++---------- 2 files changed, 161 insertions(+), 203 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index ca2c8bc71a..01b29fe814 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -69,7 +69,7 @@ import net.runelite.api.events.WidgetLoaded; import net.runelite.api.vars.AccountType; import net.runelite.api.widgets.Widget; import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID; -import static net.runelite.api.widgets.WidgetID.GENERIC_SCROLL_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID; import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; @@ -109,9 +109,9 @@ import org.apache.commons.text.WordUtils; public class ChatCommandsPlugin extends Plugin { private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (?:completion count for |subdued |completed )?(.+?) (?:(?:kill|harvest|lap|completion) )?(?:count )?is: (\\d+)"); - private static final String COX_TEAM_SIZES = "(?:\\d+(?:\\+|-\\d+)? players|Solo)"; - private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + COX_TEAM_SIZES + " Duration: (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); - private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + COX_TEAM_SIZES + " Duration: [0-9:.]+ Personal best: (?[0-9:]+(?:\\.[0-9]+)?)"); + private static final String TEAM_SIZES = "(?:\\d+(?:\\+|-\\d+)? players|Solo)"; + private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + TEAM_SIZES + " Duration: (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); + private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + TEAM_SIZES + " Duration: [0-9:.]+ Personal best: (?[0-9:]+(?:\\.[0-9]+)?)"); private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("Theatre of Blood wave completion time: (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); private static final Pattern TOB_WAVE_DURATION_PATTERN = Pattern.compile("Theatre of Blood wave completion time: [0-9:.]+\\. Personal best: (?[0-9:]+(?:\\.[0-9]+)?)"); private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)(?:(?:Fight |Lap |Challenge |Corrupted challenge )?duration:|Subdued in) [0-9:.]+\\. Personal best: (?:)?(?[0-9:]+(?:\\.[0-9]+)?)"); @@ -119,9 +119,7 @@ public class ChatCommandsPlugin extends Plugin private static final Pattern DUEL_ARENA_WINS_PATTERN = Pattern.compile("You (were defeated|won)! You have(?: now)? won (\\d+) duels?"); private static final Pattern DUEL_ARENA_LOSSES_PATTERN = Pattern.compile("You have(?: now)? lost (\\d+) duels?"); private static final Pattern ADVENTURE_LOG_TITLE_PATTERN = Pattern.compile("The Exploits of (.+)"); - private static final Pattern ADVENTURE_LOG_COX_PB_PATTERN = Pattern.compile("Fastest (?:kill|run)(?: - \\(Team size: " + COX_TEAM_SIZES + "\\))?: ([0-9:]+(?:\\.[0-9]+)?)"); - private static final Pattern ADVENTURE_LOG_BOSS_PB_PATTERN = Pattern.compile("[a-zA-Z]+(?: [a-zA-Z]+)*"); - private static final Pattern ADVENTURE_LOG_PB_PATTERN = Pattern.compile("(" + ADVENTURE_LOG_BOSS_PB_PATTERN + "(?: - " + ADVENTURE_LOG_BOSS_PB_PATTERN + ")*) (?:" + ADVENTURE_LOG_COX_PB_PATTERN + "( )*)+"); + private static final Pattern ADVENTURE_LOG_PB_PATTERN = Pattern.compile("Fastest (?:kill|run)(?: - \\(Team size: " + TEAM_SIZES + "\\))?: ([0-9:]+(?:\\.[0-9]+)?)"); private static final Pattern HS_PB_PATTERN = Pattern.compile("Floor (?\\d) time: (?[0-9:]+(?:\\.[0-9]+)?)(?: \\(new personal best\\)|. Personal best: (?[0-9:]+(?:\\.[0-9]+)?))" + "(?:
Overall time: (?[0-9:]+(?:\\.[0-9]+)?)(?: \\(new personal best\\)|. Personal best: (?[0-9:]+(?:\\.[0-9]+)?)))?"); private static final Pattern HS_KC_FLOOR_PATTERN = Pattern.compile("You have completed Floor (\\d) of the Hallowed Sepulchre! Total completions: ([0-9,]+)\\."); @@ -633,37 +631,47 @@ public class ChatCommandsPlugin extends Plugin } } + // Adventure log - Counters if (scrollInterfaceLoaded) { scrollInterfaceLoaded = false; if (client.getLocalPlayer().getName().equals(pohOwner)) { - String counterText = Text.sanitizeMultilineText(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT).getText()); - Matcher mCounterText = ADVENTURE_LOG_PB_PATTERN.matcher(counterText); - while (mCounterText.find()) + Widget parent = client.getWidget(WidgetInfo.DIARY_QUEST_WIDGET_TEXT); + // Each line is a separate static child + Widget[] children = parent.getStaticChildren(); + String[] text = Arrays.stream(children) + .map(Widget::getText) + .map(Text::removeTags) + .toArray(String[]::new); + + for (int i = 0; i < text.length; ++i) { - String bossName = longBossName(mCounterText.group(1)); - if (bossName.equalsIgnoreCase("chambers of xeric") || - bossName.equalsIgnoreCase("chambers of xeric challenge mode")) + String boss = longBossName(text[i]); + double pb = Double.MAX_VALUE; + + for (i = i + 1; i < text.length; ++i) { - Matcher mCoxRuns = ADVENTURE_LOG_COX_PB_PATTERN.matcher(mCounterText.group()); - double bestPbTime = Double.MAX_VALUE; - while (mCoxRuns.find()) + String line = text[i]; + if (line.isEmpty()) { - bestPbTime = Math.min(timeStringToSeconds(mCoxRuns.group(1)), bestPbTime); + break; } - // So we don't reset people's already saved PB's if they had one before the update - double currentPb = getPb(bossName); - if (currentPb == 0 || currentPb > bestPbTime) + + // Some bosses have multiple pbs for each team size, just use the lowest + Matcher matcher = ADVENTURE_LOG_PB_PATTERN.matcher(line); + if (matcher.find()) { - setPb(bossName, bestPbTime); + double s = timeStringToSeconds(matcher.group(1)); + pb = Math.min(pb, s); } } - else + + if (pb < Double.MAX_VALUE) { - String pbTime = mCounterText.group(2); - setPb(bossName, timeStringToSeconds(pbTime)); + log.debug("Found adventure log PB for {}: {}", boss, pb); + setPb(boss, pb); } } } @@ -722,7 +730,7 @@ public class ChatCommandsPlugin extends Plugin case KILL_LOGS_GROUP_ID: bossLogLoaded = true; break; - case GENERIC_SCROLL_GROUP_ID: + case DIARY_QUEST_GROUP_ID: scrollInterfaceLoaded = true; break; } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java index 7fa2c8dde5..5fe725c00f 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java @@ -30,6 +30,7 @@ import com.google.inject.Guice; import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; import java.io.IOException; +import java.util.Arrays; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; import net.runelite.api.ChatMessageType; @@ -46,7 +47,7 @@ import net.runelite.api.events.ScriptPostFired; import net.runelite.api.events.WidgetLoaded; import net.runelite.api.widgets.Widget; import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID; -import static net.runelite.api.widgets.WidgetID.GENERIC_SCROLL_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.chat.ChatCommandManager; import net.runelite.client.chat.ChatMessageManager; @@ -66,11 +67,9 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import org.mockito.junit.MockitoJUnitRunner; @@ -541,181 +540,6 @@ public class ChatCommandsPluginTest verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 20 * 60 + 19.2); } - @Test - public void testAdventureLogCountersPage() - { - Widget advLogWidget = mock(Widget.class); - Widget advLogExploitsTextWidget = mock(Widget.class); - when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); - when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + PLAYER_NAME); - when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); - when(configManager.getRSProfileConfiguration(anyString(), anyString(), any(Class.class))).thenReturn(2224.0); - - WidgetLoaded advLogEvent = new WidgetLoaded(); - advLogEvent.setGroupId(ADVENTURE_LOG_ID); - chatCommandsPlugin.onWidgetLoaded(advLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - String COUNTER_TEXT = "Duel Arena
Wins: 4
Losses: 2" + - "

Last Man Standing
Rank: 0" + - "

Treasure Trails
Beginner: 0
Easy: 7" + - "
Medium: 28
Hard: 108
Elite: 15" + - "
Master: 27
Rank: Novice" + - "

Chompy Hunting
Kills: 1,000
Rank: Ogre Expert" + - "

Order of the White Knights
Rank: Master
with a kill score of 1,300" + - "

TzHaar Fight Cave
Fastest run: 38:10" + - "

Inferno
Fastest run: -

Zulrah
" + - "Fastest kill: 5:48

Vorkath
Fastest kill: 1:21" + - "

Galvek
Fastest kill: -

Grotesque Guardians
" + - "Fastest kill: 2:49

Alchemical Hydra
Fastest kill: -" + - "

Hespori
Fastest kill: 0:57

Nightmare
" + - "Fastest kill: 3:30

The Gauntlet
Fastest run: -" + - "

The Corrupted Gauntlet
Fastest run: -

Fragment of Seren
Fastest kill: -" + - "

Chambers of Xeric
Fastest run - (Team size: 24+ players): 24:17" + - "

Chambers of Xeric - Challenge mode
Fastest run - (Team size: Solo): 22:15" + - "

Barbarian Assault
High-level gambles: 0

Fremennik spirits rested: 0"; - - Widget countersPage = mock(Widget.class); - when(countersPage.getText()).thenReturn(COUNTER_TEXT); - when(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT)).thenReturn(countersPage); - - WidgetLoaded countersLogEvent = new WidgetLoaded(); - countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); - chatCommandsPlugin.onWidgetLoaded(countersLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 38 * 60 + 10.0); - verify(configManager).setRSProfileConfiguration("personalbest", "zulrah", 5 * 60 + 48.0); - verify(configManager).setRSProfileConfiguration("personalbest", "vorkath", 60 + 21.0); - verify(configManager).setRSProfileConfiguration("personalbest", "grotesque guardians", 2 * 60 + 49.0); - verify(configManager).setRSProfileConfiguration("personalbest", "hespori", 57.0); - verify(configManager).setRSProfileConfiguration("personalbest", "nightmare", 3 * 60 + 30.0); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 24 * 60 + 17.0); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric challenge mode", 22 * 60 + 15.0); - } - - @Test - public void testAdventurerLogCountersPage2() - { - Widget advLogWidget = mock(Widget.class); - Widget advLogExploitsTextWidget = mock(Widget.class); - when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); - when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + PLAYER_NAME); - when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); - - WidgetLoaded advLogEvent = new WidgetLoaded(); - advLogEvent.setGroupId(ADVENTURE_LOG_ID); - chatCommandsPlugin.onWidgetLoaded(advLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - String COUNTER_TEXT = "Duel Arena
Wins: 12
Losses: 20" + - "

Last Man Standing
Rank: 0" + - "

Treasure Trails
Beginner: 1
Easy: 4" + - "
Medium: 35
Hard: 66
Elite: 2" + - "
Master: 0
Rank: Novice" + - "

Chompy Hunting
Kills: 300
Rank: Ogre Forester" + - "

Order of the White Knights
Rank: Unrated
with a kill score of 99" + - "

TzHaar Fight Cave
Fastest run: 65:12" + - "

Inferno
Fastest run: -

Zulrah
" + - "Fastest kill: 2:55

Vorkath
Fastest kill: 1:37" + - "

Galvek
Fastest kill: -

Grotesque Guardians
" + - "Fastest kill: -

Alchemical Hydra
Fastest kill: -" + - "

Hespori
Fastest kill: 1:42

Nightmare
" + - "Fastest kill: -

The Gauntlet
Fastest run: -" + - "

The Corrupted Gauntlet
Fastest run: -

Fragment of Seren
Fastest kill: -" + - "

Chambers of Xeric
Fastest run - (Team size: Solo): 21:23
Fastest run - (Team size: 3 players): 27:16" + - "

Chambers of Xeric - Challenge mode
Fastest run - (Team size: Solo): 34:30
Fastest run - (Team size: 4 players): 21:26" + - "

Barbarian Assault
High-level gambles: 0

Fremennik spirits rested: 0"; - - Widget countersPage = mock(Widget.class); - when(countersPage.getText()).thenReturn(COUNTER_TEXT); - when(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT)).thenReturn(countersPage); - - WidgetLoaded countersLogEvent = new WidgetLoaded(); - countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); - chatCommandsPlugin.onWidgetLoaded(countersLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 65 * 60 + 12.0); - verify(configManager).setRSProfileConfiguration("personalbest", "zulrah", 2 * 60 + 55.0); - verify(configManager).setRSProfileConfiguration("personalbest", "vorkath", 60 + 37.0); - verify(configManager).setRSProfileConfiguration("personalbest", "hespori", 60 + 42.0); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 21 * 60 + 23.0); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric challenge mode", 21 * 60 + 26.0); - } - - @Test - public void testAdventurerLogCountersPagePrecise() - { - Widget advLogWidget = mock(Widget.class); - Widget advLogExploitsTextWidget = mock(Widget.class); - when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); - when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + PLAYER_NAME); - when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); - - WidgetLoaded advLogEvent = new WidgetLoaded(); - advLogEvent.setGroupId(ADVENTURE_LOG_ID); - chatCommandsPlugin.onWidgetLoaded(advLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - String COUNTER_TEXT = "Duel Arena
Wins: 12
Losses: 20" + - "

Last Man Standing
Rank: 0" + - "

Treasure Trails
Beginner: 1
Easy: 4" + - "
Medium: 35
Hard: 66
Elite: 2" + - "
Master: 0
Rank: Novice" + - "

Chompy Hunting
Kills: 300
Rank: Ogre Forester" + - "

Order of the White Knights
Rank: Unrated
with a kill score of 99" + - "

TzHaar Fight Cave
Fastest run: 65:12.00" + - "

Inferno
Fastest run: -

Zulrah
" + - "Fastest kill: 2:55.20

Vorkath
Fastest kill: 1:37.20" + - "

Galvek
Fastest kill: -

Grotesque Guardians
" + - "Fastest kill: -

Alchemical Hydra
Fastest kill: -" + - "

Hespori
Fastest kill: 1:42.40

Nightmare
" + - "Fastest kill: -

The Gauntlet
Fastest run: -" + - "

The Corrupted Gauntlet
Fastest run: -

Fragment of Seren
Fastest kill: -" + - "

Chambers of Xeric
Fastest run - (Team size: Solo): 21:23.20
Fastest run - (Team size: 3 players): 27:16.40" + - "

Chambers of Xeric - Challenge mode
Fastest run - (Team size: Solo): 34:30.20
Fastest run - (Team size: 4 players): 21:26.00" + - "

Barbarian Assault
High-level gambles: 0

Fremennik spirits rested: 0"; - - Widget countersPage = mock(Widget.class); - when(countersPage.getText()).thenReturn(COUNTER_TEXT); - when(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT)).thenReturn(countersPage); - - WidgetLoaded countersLogEvent = new WidgetLoaded(); - countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); - chatCommandsPlugin.onWidgetLoaded(countersLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 65 * 60 + 12.0); - verify(configManager).setRSProfileConfiguration("personalbest", "zulrah", 2 * 60 + 55.2); - verify(configManager).setRSProfileConfiguration("personalbest", "vorkath", 60 + 37.2); - verify(configManager).setRSProfileConfiguration("personalbest", "hespori", 60 + 42.40); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 21 * 60 + 23.20); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric challenge mode", 21 * 60 + 26.0); - } - - @Test - public void testNotYourAdventureLogCountersPage() - { - Widget advLogWidget = mock(Widget.class); - Widget advLogExploitsTextWidget = mock(Widget.class); - when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); - when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + "not the player"); - when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); - - WidgetLoaded advLogEvent = new WidgetLoaded(); - advLogEvent.setGroupId(ADVENTURE_LOG_ID); - chatCommandsPlugin.onWidgetLoaded(advLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - WidgetLoaded countersLogEvent = new WidgetLoaded(); - countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); - chatCommandsPlugin.onWidgetLoaded(countersLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - verifyNoMoreInteractions(configManager); - } - @Test public void testPlayerSkillLookup() throws IOException { @@ -1122,4 +946,130 @@ public class ChatCommandsPluginTest // h:mm:ss assertEquals(2 * 3600 + 50 * 60 + 30.2, ChatCommandsPlugin.timeStringToSeconds("2:50:30.20"), DELTA); } + + @Test + public void testCounters() + { + final String[] log = { + "Chompy Hunting", + "Kills: 1,003", + "Rank: Ogre Expert", + "", + "Order of the White Knights", + "Rank: Master", + "with a kill score of 1,300", + "", + "TzHaar Fight Cave", + "Fastest run: 33:53", + "", + "Inferno", + "Fastest run: 2:02:20", + "", + "Zulrah", + "Fastest kill: 0:47", + "", + "Vorkath", + "Fastest kill: 1:04", + "", + "Galvek", + "Fastest kill: -", + "", + "Grotesque Guardians", + "Fastest kill: 1:20", + "", + "Alchemical Hydra", + "Fastest kill: 1:34", + "", + "Hespori", + "Fastest kill: 1:24", + "", + // Nightmare is here 3x! + "Nightmare", // including one only called "Nightmare" + "Fastest kill: -", // with no time + "", + "The Nightmare", + "Fastest kill - (Team size: 6+ players): 3:22", + "", + "The Nightmare", + "Fastest kill - (Team size: 6+ players): 3:22", + "", + "Phosani's Nightmare", + "Fastest kill: -", + "", + "The Gauntlet", + "Fastest run: -", + "", + "The Corrupted Gauntlet", + "Fastest run: -", + "", + "Fragment of Seren", + "Fastest kill: -", + "", + "Chambers of Xeric", + "Fastest run - (Team size: Solo): 28:07", + "Fastest run - (Team size: 2 players): 24:40", + "Fastest run - (Team size: 3 players): 25:35", + "Fastest run - (Team size: 4 players): 22:40", + "Fastest run - (Team size: 5 players): 23:00", + "Fastest run - (Team size: 6 players): 28:11", + "", + "Chambers of Xeric - Challenge mode", + "Fastest run - (Team size: 3 players): 45:41", + "", + "Theatre of Blood", + "Fastest Room time (former): 18:45", + "Fastest Wave time (former): 22:01", + "Fastest Room time - (Team size: (3 player): 19:50", + "Fastest Overall time - (Team size: 3 player): 22:47", + "Fastest Room time - (Team size: (4 player): 17:38", + "Fastest Overall time - (Team size: 4 player): 20:31", + "Fastest Room time - (Team size: (5 player): 18:45", + "Fastest Overall time - (Team size: 5 player): 22:01", + "", + "Tempoross", + "Fastest run: 3:54", + "", + "Barbarian Assault", + "High-level gambles: 0", + "", + "Fremennik spirits rested: 0", + }; + + // adv log + Widget advLogWidget = mock(Widget.class); + Widget advLogExploitsTextWidget = mock(Widget.class); + when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); + when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + PLAYER_NAME); + when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); + + // counters + when(client.getWidget(WidgetInfo.DIARY_QUEST_WIDGET_TEXT)).thenAnswer(a -> + { + Widget widget = mock(Widget.class); + Widget[] children = Arrays.stream(log) + .map(s -> + { + Widget w = mock(Widget.class); + when(w.getText()).thenReturn(s); + return w; + }) + .toArray(Widget[]::new); + when(widget.getStaticChildren()).thenReturn(children); + return widget; + }); + + WidgetLoaded advLogEvent = new WidgetLoaded(); + advLogEvent.setGroupId(ADVENTURE_LOG_ID); + chatCommandsPlugin.onWidgetLoaded(advLogEvent); + chatCommandsPlugin.onGameTick(new GameTick()); + + WidgetLoaded countersLogEvent = new WidgetLoaded(); + countersLogEvent.setGroupId(DIARY_QUEST_GROUP_ID); + chatCommandsPlugin.onWidgetLoaded(countersLogEvent); + chatCommandsPlugin.onGameTick(new GameTick()); + + verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 2033.0); + verify(configManager).setRSProfileConfiguration("personalbest", "tempoross", 234.0); + verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 1360.0); // the lowest time + } } From b695ca8689a4e06dcab52b0e7b0ca2c3e74bf5c5 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 24 Aug 2021 18:59:55 -0400 Subject: [PATCH 5/5] ge: fix detecting dmmt world type --- .../plugins/grandexchange/GrandExchangePlugin.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java index a93b06a90f..53f3276b12 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java @@ -479,14 +479,14 @@ public class GrandExchangePlugin extends Plugin private WorldType getGeWorldType() { EnumSet worldTypes = client.getWorldType(); - if (worldTypes.contains(net.runelite.api.WorldType.DEADMAN)) - { - return WorldType.DEADMAN; - } - else if (worldTypes.contains(net.runelite.api.WorldType.DEADMAN_TOURNAMENT)) + if (worldTypes.contains(net.runelite.api.WorldType.DEADMAN_TOURNAMENT)) { return WorldType.DEADMAN_TOURNAMENT; } + else if (worldTypes.contains(net.runelite.api.WorldType.DEADMAN)) + { + return WorldType.DEADMAN; + } else { return null;