From b640c22c75bad9e18fff85830f2bbc557a04ce33 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 23 Mar 2022 23:07:14 -0400 Subject: [PATCH] loot tracker: fix race with loading saved loot and client startup switchProfile can be run in early client startup via either startUp or the profile change event caused from the client remember username feature. Item compositions cannot be accessed this early and will throw an exception, causing the loot to fail to load. --- .../client/plugins/loottracker/LootTrackerPlugin.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index 08b41df095..5d570d52ff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -486,6 +486,13 @@ public class LootTrackerPlugin extends Plugin clientThread.invokeLater(() -> { + // convertToLootTrackerRecord requires item compositions to be available to get the item name, + // so it can't be run while the client is starting + if (client.getGameState().getState() < GameState.LOGIN_SCREEN.getState()) + { + return false; + } + // convertToLootTrackerRecord must be called on client thread List records = loots.stream() .map(this::convertToLootTrackerRecord) @@ -495,6 +502,8 @@ public class LootTrackerPlugin extends Plugin panel.clearRecords(); panel.addRecords(records); }); + + return true; }); }); }