Search in sources :

Example 1 with NPCComposition

use of net.runelite.api.NPCComposition in project runelite by runelite.

the class MenuManager method removeNpcMenuOption.

public void removeNpcMenuOption(String option) {
    npcMenuOptions.remove(option);
    // remove this option from all npc compositions
    Client client = clientProvider.get();
    if (client == null) {
        return;
    }
    for (NPC npc : client.getNpcs()) {
        NPCComposition composition = npc.getComposition();
        removeNpcOption(composition, option);
    }
}
Also used : NPC(net.runelite.api.NPC) NPCComposition(net.runelite.api.NPCComposition) Client(net.runelite.api.Client)

Example 2 with NPCComposition

use of net.runelite.api.NPCComposition in project runelite by runelite.

the class MenuManager method addNpcMenuOption.

public void addNpcMenuOption(String option) {
    npcMenuOptions.add(option);
    // add to surrounding npcs
    Client client = clientProvider.get();
    if (client == null) {
        return;
    }
    for (NPC npc : client.getNpcs()) {
        NPCComposition composition = npc.getComposition();
        addNpcOption(composition, option);
    }
}
Also used : NPC(net.runelite.api.NPC) NPCComposition(net.runelite.api.NPCComposition) Client(net.runelite.api.Client)

Example 3 with NPCComposition

use of net.runelite.api.NPCComposition in project runelite by runelite.

the class NpcIndicatorsPlugin method onGameTick.

@Subscribe
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())) {
            NPCComposition composition = getComposition(npc);
            if (composition == null || composition.getName() == null)
                continue;
            taggedNpcs.add(npc);
        }
    }
}
Also used : NPC(net.runelite.api.NPC) NPCComposition(net.runelite.api.NPCComposition) Subscribe(com.google.common.eventbus.Subscribe)

Example 4 with NPCComposition

use of net.runelite.api.NPCComposition in project runelite by runelite.

the class NpcIndicatorsPlugin method buildNpcsToHighlight.

private Map<NPC, String> buildNpcsToHighlight() {
    String configNpcs = config.getNpcToHighlight().toLowerCase();
    if (configNpcs.isEmpty())
        return Collections.EMPTY_MAP;
    Map<NPC, String> npcMap = new HashMap<>();
    List<String> highlightedNpcs = Arrays.asList(configNpcs.split(DELIMITER_REGEX));
    for (NPC npc : client.getNpcs()) {
        NPCComposition composition = getComposition(npc);
        if (npc == null || composition == null || composition.getName() == null)
            continue;
        for (String highlight : highlightedNpcs) {
            String name = composition.getName().replace('\u00A0', ' ');
            if (WildcardMatcher.matches(highlight, name)) {
                npcMap.put(npc, name);
            }
        }
    }
    return npcMap;
}
Also used : NPC(net.runelite.api.NPC) HashMap(java.util.HashMap) NPCComposition(net.runelite.api.NPCComposition)

Example 5 with NPCComposition

use of net.runelite.api.NPCComposition in project runelite by runelite.

the class NpcClickboxOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    Map<NPC, String> npcMap = plugin.getHighlightedNpcs();
    for (NPC npc : npcMap.keySet()) {
        renderNpcOverlay(graphics, npc, npcMap.get(npc), config.getNpcColor());
    }
    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());
    }
    return null;
}
Also used : NPC(net.runelite.api.NPC) NPCComposition(net.runelite.api.NPCComposition)

Aggregations

NPC (net.runelite.api.NPC)6 NPCComposition (net.runelite.api.NPCComposition)6 Client (net.runelite.api.Client)2 Subscribe (com.google.common.eventbus.Subscribe)1 HashMap (java.util.HashMap)1