From 97c484fc3866fa6329be8f2aeeb073bd56d2d1c7 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 3 Jan 2022 12:08:55 -0500 Subject: [PATCH] world map: use game state change event to load quest icons This was queueing potentially multiple tasks if the config was changed on the login screen, all waiting for the player to be logged in. Instead, use the game state change event to load the icons. --- .../client/callback/ClientThread.java | 4 ++++ .../plugins/worldmap/WorldMapPlugin.java | 23 ++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/callback/ClientThread.java b/runelite-client/src/main/java/net/runelite/client/callback/ClientThread.java index 2470b55056..17d2ffb177 100644 --- a/runelite-client/src/main/java/net/runelite/client/callback/ClientThread.java +++ b/runelite-client/src/main/java/net/runelite/client/callback/ClientThread.java @@ -110,6 +110,10 @@ public class ClientThread { ir.remove(); } + else + { + log.trace("Deferring task {}", r); + } } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java index cfe7714b5e..fcc2519ac9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java @@ -34,6 +34,7 @@ import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Quest; import net.runelite.api.Skill; +import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.StatChanged; import net.runelite.api.events.WidgetLoaded; import net.runelite.api.widgets.WidgetID; @@ -168,6 +169,15 @@ public class WorldMapPlugin extends Plugin woodcuttingLevel = 0; } + @Subscribe + public void onGameStateChanged(GameStateChanged gameStateChanged) + { + if (gameStateChanged.getGameState() == GameState.LOGGED_IN) + { + updateQuestStartPointIcons(); + } + } + @Subscribe public void onConfigChanged(ConfigChanged event) { @@ -488,17 +498,14 @@ public class WorldMapPlugin extends Plugin } // Must setup the quest icons on the client thread, after the player has logged in. - clientThread.invokeLater(() -> + clientThread.invoke(() -> { - if (client.getGameState() != GameState.LOGGED_IN) + if (client.getGameState() == GameState.LOGGED_IN) { - return false; + Arrays.stream(QuestStartLocation.values()) + .map(this::createQuestStartPoint) + .forEach(worldMapPointManager::add); } - - Arrays.stream(QuestStartLocation.values()) - .map(this::createQuestStartPoint) - .forEach(worldMapPointManager::add); - return true; }); }