From f0b7be68ba2a6d47f5102dffbc92bd5953d209c5 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Fri, 10 Jul 2020 17:20:43 -0600 Subject: [PATCH] npchighlight: factor out npc name tag checking --- .../npchighlight/NpcIndicatorsPlugin.java | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) 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 0990ff39a7..5a6c0a746c 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 @@ -385,17 +385,13 @@ public class NpcIndicatorsPlugin extends Plugin return; } - for (String highlight : highlights) + if (highlightMatchesNPCName(npcName)) { - if (WildcardMatcher.matches(highlight, npcName)) + highlightedNpcs.add(npc); + if (!client.isInInstancedRegion()) { - highlightedNpcs.add(npc); - if (!client.isInInstancedRegion()) - { - memorizeNpc(npc); - spawnedNpcsThisTick.add(npc); - } - break; + memorizeNpc(npc); + spawnedNpcsThisTick.add(npc); } } } @@ -529,7 +525,6 @@ public class NpcIndicatorsPlugin extends Plugin return; } - outer: for (NPC npc : client.getNpcs()) { final String npcName = npc.getName(); @@ -545,17 +540,14 @@ public class NpcIndicatorsPlugin extends Plugin continue; } - for (String highlight : highlights) + if (highlightMatchesNPCName(npcName)) { - if (WildcardMatcher.matches(highlight, npcName)) + if (!client.isInInstancedRegion()) { - if (!client.isInInstancedRegion()) - { - memorizeNpc(npc); - } - highlightedNpcs.add(npc); - continue outer; + memorizeNpc(npc); } + highlightedNpcs.add(npc); + continue; } // NPC is not highlighted @@ -563,6 +555,19 @@ public class NpcIndicatorsPlugin extends Plugin } } + private boolean highlightMatchesNPCName(String npcName) + { + for (String highlight : highlights) + { + if (WildcardMatcher.matches(highlight, npcName)) + { + return true; + } + } + + return false; + } + private void validateSpawnedNpcs() { if (skipNextSpawnCheck)