npc indicators: remove unnecessary tagged npcs list

This commit is contained in:
Adam
2018-05-06 20:40:30 -04:00
parent 4126be0a36
commit b29f2ff0ed
3 changed files with 24 additions and 23 deletions

View File

@@ -65,10 +65,14 @@ public class NpcClickboxOverlay extends Overlay
renderNpcOverlay(graphics, npc, npcMap.get(npc), config.getNpcColor());
}
for (NPC npc : plugin.getTaggedNpcs())
NPC[] npcs = client.getCachedNPCs();
for (int npcId : plugin.getNpcTags())
{
String npcName = npc.getName();
renderNpcOverlay(graphics, npc, npcName, config.getTagColor());
NPC npc = npcs[npcId];
if (npc != null && npc.getName() != null)
{
renderNpcOverlay(graphics, npc, npc.getName(), config.getTagColor());
}
}
return null;

View File

@@ -27,7 +27,6 @@ package net.runelite.client.plugins.npchighlight;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -82,12 +81,15 @@ public class NpcIndicatorsPlugin extends Plugin
@Inject
private KeyManager keyManager;
/**
* NPCs tagged with the Tag option
*/
@Getter(AccessLevel.PACKAGE)
private final Set<Integer> npcTags = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private final List<NPC> taggedNpcs = new ArrayList<>();
/**
* NPCs tagged due to highlight in the config
*/
@Getter(AccessLevel.PACKAGE)
private Map<NPC, String> highlightedNpcs = new HashMap<>();
@@ -116,7 +118,6 @@ public class NpcIndicatorsPlugin extends Plugin
protected void shutDown() throws Exception
{
npcTags.clear();
taggedNpcs.clear();
keyManager.unregisterKeyListener(inputListener);
}
@@ -141,18 +142,6 @@ public class NpcIndicatorsPlugin extends Plugin
public void onGameTick(GameTick tick)
{
highlightedNpcs = buildNpcsToHighlight();
taggedNpcs.clear();
if (npcTags.isEmpty() || !config.isTagEnabled())
{
return;
}
for (NPC npc : client.getNpcs())
{
if (npcTags.contains(npc.getIndex()) && npc.getName() != null)
{
taggedNpcs.add(npc);
}
}
}
@Override

View File

@@ -30,6 +30,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D;
import java.util.Map;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.NPC;
import net.runelite.api.Point;
import net.runelite.client.ui.overlay.Overlay;
@@ -39,12 +40,14 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class NpcMinimapOverlay extends Overlay
{
private final Client client;
private final NpcIndicatorsConfig config;
private final NpcIndicatorsPlugin plugin;
@Inject
NpcMinimapOverlay(NpcIndicatorsConfig config, NpcIndicatorsPlugin plugin)
NpcMinimapOverlay(Client client, NpcIndicatorsConfig config, NpcIndicatorsPlugin plugin)
{
this.client = client;
this.config = config;
this.plugin = plugin;
setPosition(OverlayPosition.DYNAMIC);
@@ -60,9 +63,14 @@ public class NpcMinimapOverlay extends Overlay
renderNpcOverlay(graphics, npc, npcMap.get(npc), config.getNpcColor());
}
for (NPC npc : plugin.getTaggedNpcs())
NPC[] npcs = client.getCachedNPCs();
for (int npcId : plugin.getNpcTags())
{
renderNpcOverlay(graphics, npc, npc.getName(), config.getTagColor());
NPC npc = npcs[npcId];
if (npc != null && npc.getName() != null)
{
renderNpcOverlay(graphics, npc, npc.getName(), config.getTagColor());
}
}
return null;