npc mixin: transform npc in getName/getCombatLevel/getId

This commit is contained in:
Adam
2018-04-23 19:38:09 -04:00
parent 0edfbb59b6
commit 3caf182b0b
4 changed files with 19 additions and 42 deletions

View File

@@ -34,7 +34,6 @@ import java.util.Map;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.NPC;
import net.runelite.api.NPCComposition;
import net.runelite.api.Point;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
@@ -68,13 +67,8 @@ public class NpcClickboxOverlay extends Overlay
for (NPC npc : plugin.getTaggedNpcs())
{
NPCComposition composition = plugin.getComposition(npc);
if (composition == null || composition.getName() == null)
continue;
String name = composition.getName().replace('\u00A0', ' ');
renderNpcOverlay(graphics, npc, name, config.getTagColor());
String npcName = npc.getName();
renderNpcOverlay(graphics, npc, npcName, config.getTagColor());
}
return null;

View File

@@ -41,7 +41,6 @@ import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.NPC;
import net.runelite.api.NPCComposition;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.MenuOptionClicked;
@@ -149,12 +148,8 @@ public class NpcIndicatorsPlugin extends Plugin
}
for (NPC npc : client.getNpcs())
{
if (npcTags.contains(npc.getIndex()))
if (npcTags.contains(npc.getIndex()) && npc.getName() != null)
{
NPCComposition composition = getComposition(npc);
if (composition == null || composition.getName() == null)
continue;
taggedNpcs.add(npc);
}
}
@@ -177,17 +172,13 @@ public class NpcIndicatorsPlugin extends Plugin
for (NPC npc : client.getNpcs())
{
NPCComposition composition = getComposition(npc);
if (npc == null || composition == null || composition.getName() == null)
continue;
String npcName = npc.getName();
for (String highlight : highlightedNpcs)
{
String name = composition.getName().replace('\u00A0', ' ');
if (WildcardMatcher.matches(highlight, name))
if (WildcardMatcher.matches(highlight, npcName))
{
npcMap.put(npc, name);
npcMap.put(npc, npcName);
}
}
}
@@ -195,26 +186,6 @@ public class NpcIndicatorsPlugin extends Plugin
return npcMap;
}
/**
* Get npc composition, account for imposters
*
* @param npc
* @return
*/
protected NPCComposition getComposition(NPC npc)
{
if (npc == null)
return null;
NPCComposition composition = npc.getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
return composition;
}
void updateNpcMenuOptions(boolean pressed)
{
if (!config.isTagEnabled())

View File

@@ -438,7 +438,7 @@ public class SlayerPlugin extends Plugin
if (composition == null || composition.getName() == null)
continue;
String name = composition.getName().replace('\u00A0', ' ');
String name = npc.getName();
for (String highlight : highlightedNpcs)
{
if (name.toLowerCase().contains(highlight.toLowerCase())

View File

@@ -48,6 +48,10 @@ public abstract class RSNPCMixin implements RSNPC
public int getId()
{
RSNPCComposition composition = getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
return composition == null ? -1 : composition.getId();
}
@@ -56,6 +60,10 @@ public abstract class RSNPCMixin implements RSNPC
public String getName()
{
RSNPCComposition composition = getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
return composition == null ? null : composition.getName().replace('\u00A0', ' ');
}
@@ -64,6 +72,10 @@ public abstract class RSNPCMixin implements RSNPC
public int getCombatLevel()
{
RSNPCComposition composition = getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
return composition == null ? -1 : composition.getCombatLevel();
}