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 4b9ad27bcf..24e5bbf9a5 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 @@ -187,7 +187,6 @@ public class NpcIndicatorsPlugin extends Plugin { overlayManager.add(npcSceneOverlay); overlayManager.add(npcMinimapOverlay); - highlights = getHighlights(); clientThread.invoke(() -> { skipNextSpawnCheck = true; @@ -200,13 +199,16 @@ public class NpcIndicatorsPlugin extends Plugin { overlayManager.remove(npcSceneOverlay); overlayManager.remove(npcMinimapOverlay); - deadNpcsToDisplay.clear(); - memorizedNpcs.clear(); - spawnedNpcsThisTick.clear(); - despawnedNpcsThisTick.clear(); - teleportGraphicsObjectSpawnedThisTick.clear(); - npcTags.clear(); - highlightedNpcs.clear(); + clientThread.invoke(() -> + { + deadNpcsToDisplay.clear(); + memorizedNpcs.clear(); + spawnedNpcsThisTick.clear(); + despawnedNpcsThisTick.clear(); + teleportGraphicsObjectSpawnedThisTick.clear(); + npcTags.clear(); + highlightedNpcs.clear(); + }); } @Subscribe @@ -231,8 +233,7 @@ public class NpcIndicatorsPlugin extends Plugin return; } - highlights = getHighlights(); - rebuildAllNpcs(); + clientThread.invoke(this::rebuildAllNpcs); } @Subscribe @@ -516,8 +517,10 @@ public class NpcIndicatorsPlugin extends Plugin return Text.fromCSV(configNpcs); } - private void rebuildAllNpcs() + @VisibleForTesting + void rebuildAllNpcs() { + highlights = getHighlights(); highlightedNpcs.clear(); if (client.getGameState() != GameState.LOGGED_IN && diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java index 7884a7c81b..1260c5df0d 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java @@ -38,7 +38,6 @@ import net.runelite.api.MenuEntry; import net.runelite.api.NPC; import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.NpcSpawned; -import net.runelite.client.events.ConfigChanged; import net.runelite.client.ui.overlay.OverlayManager; import static org.junit.Assert.assertEquals; import org.junit.Before; @@ -97,9 +96,7 @@ public class NpcIndicatorsPluginTest when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin"); when(npcIndicatorsConfig.deadNpcMenuColor()).thenReturn(Color.RED); - ConfigChanged configChanged = new ConfigChanged(); - configChanged.setGroup("npcindicators"); - npcIndicatorsPlugin.onConfigChanged(configChanged); + npcIndicatorsPlugin.rebuildAllNpcs(); NPC npc = mock(NPC.class); when(npc.getName()).thenReturn("Goblin"); @@ -124,9 +121,7 @@ public class NpcIndicatorsPluginTest when(npcIndicatorsConfig.highlightMenuNames()).thenReturn(true); when(npcIndicatorsConfig.getHighlightColor()).thenReturn(Color.BLUE); - ConfigChanged configChanged = new ConfigChanged(); - configChanged.setGroup("npcindicators"); - npcIndicatorsPlugin.onConfigChanged(configChanged); + npcIndicatorsPlugin.rebuildAllNpcs(); NPC npc = mock(NPC.class); when(npc.getName()).thenReturn("Goblin");