npc overlay: clear highlighted npcs on logout

Despawn events don't fire for npcs on logout, copied from the npc highlight plugin
This commit is contained in:
Adam
2021-09-11 10:53:05 -04:00
parent 9cd1cbcea0
commit 3c5f812331

View File

@@ -33,7 +33,9 @@ import java.util.function.Function;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
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;
@@ -62,6 +64,16 @@ public class NpcOverlayService
eventBus.register(this);
}
@Subscribe
private void onGameStateChanged(GameStateChanged event)
{
if (event.getGameState() == GameState.LOGIN_SCREEN ||
event.getGameState() == GameState.HOPPING)
{
highlightedNpcs.clear();
}
}
@Subscribe(
// Run after plugins, which typically capture NPCs on spawn and reference them in the highlight functions
priority = -1