diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 26866c534f..659529b00a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -183,6 +183,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener String message = setMessage.getValue(); MessageNode messageNode = setMessage.getMessageNode(); + HiscoreEndpoint localEndpoint = getHiscoreEndpointType(); // clear RuneLite formatted message as the message node is // being reused @@ -191,7 +192,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener if (config.lvl() && message.toLowerCase().equals(TOTAL_LEVEL_COMMAND_STRING)) { log.debug("Running total level lookup"); - executor.submit(() -> playerSkillLookup(setMessage, "total")); + executor.submit(() -> playerSkillLookup(setMessage, localEndpoint, "total")); } else if (config.lvl() && message.toLowerCase().equals(CMB_COMMAND_STRING)) { @@ -210,19 +211,19 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener String search = message.substring(LEVEL_COMMAND_STRING.length() + 1); log.debug("Running level lookup for {}", search); - executor.submit(() -> playerSkillLookup(setMessage, search)); + executor.submit(() -> playerSkillLookup(setMessage, localEndpoint, search)); } else if (config.clue() && message.toLowerCase().equals(CLUES_COMMAND_STRING)) { log.debug("Running lookup for overall clues"); - executor.submit(() -> playerClueLookup(setMessage, "total")); + executor.submit(() -> playerClueLookup(setMessage, localEndpoint, "total")); } else if (config.clue() && message.toLowerCase().startsWith(CLUES_COMMAND_STRING + " ")) { String search = message.substring(CLUES_COMMAND_STRING.length() + 1); log.debug("Running clue lookup for {}", search); - executor.submit(() -> playerClueLookup(setMessage, search)); + executor.submit(() -> playerClueLookup(setMessage, localEndpoint, search)); } else if (config.killcount() && message.toLowerCase().startsWith(KILLCOUNT_COMMAND_STRING + " ")) { @@ -499,9 +500,10 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener * response. * * @param setMessage The chat message containing the command. + * @param local HiscoreEndpoint for local player, needs to be sent in advance to avoid threading bugs * @param search The item given with the command. */ - private void playerSkillLookup(SetMessage setMessage, String search) + private void playerSkillLookup(SetMessage setMessage, HiscoreEndpoint local, String search) { search = SkillAbbreviations.getFullName(search); final HiscoreSkill skill; @@ -514,7 +516,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener return; } - final HiscoreLookup lookup = getCorrectLookupFor(setMessage); + final HiscoreLookup lookup = getCorrectLookupFor(setMessage, local); try { @@ -638,9 +640,9 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener * for the requested clue-level (no arg if requesting total) * easy, medium, hard, elite, master */ - private void playerClueLookup(SetMessage setMessage, String search) + private void playerClueLookup(SetMessage setMessage, HiscoreEndpoint local, String search) { - final HiscoreLookup lookup = getCorrectLookupFor(setMessage); + final HiscoreLookup lookup = getCorrectLookupFor(setMessage, local); try { @@ -717,9 +719,10 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener * Gets correct lookup data for message * * @param setMessage chat message + * @param local HiscoreEndpoint for local player, needs to be sent in advance to avoid threading bugs * @return hiscore lookup data */ - private HiscoreLookup getCorrectLookupFor(final SetMessage setMessage) + private HiscoreLookup getCorrectLookupFor(final SetMessage setMessage, final HiscoreEndpoint local) { final String player; final HiscoreEndpoint ironmanStatus; @@ -727,7 +730,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener if (setMessage.getType().equals(ChatMessageType.PRIVATE_MESSAGE_SENT)) { player = client.getLocalPlayer().getName(); - ironmanStatus = getHiscoreEndpointType(); + ironmanStatus = local; } else {