From 3771444b7f49b61b4b48d6d3b034ce2bae7fa1ac Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 4 Dec 2020 15:50:21 -0500 Subject: [PATCH] chat commands: fix detecting pb when completing leagues tasks The league task message is in between the kc and pb messages, so just look for the pb message on the same tick as the kc message --- .../plugins/chatcommands/ChatCommandsPlugin.java | 10 +++++++++- .../chatcommands/ChatCommandsPluginTest.java | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) 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 d35214805a..9f24c06faa 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 @@ -137,6 +137,7 @@ public class ChatCommandsPlugin extends Plugin private String pohOwner; private HiscoreEndpoint hiscoreEndpoint; // hiscore endpoint for current player private String lastBossKill; + private int lastBossTime = -1; private int lastPb = -1; @Inject @@ -197,6 +198,7 @@ public class ChatCommandsPlugin extends Plugin public void shutDown() { lastBossKill = null; + lastBossTime = -1; keyManager.unregisterKeyListener(chatKeyboardListener); @@ -279,6 +281,7 @@ public class ChatCommandsPlugin extends Plugin else { lastBossKill = boss; + lastBossTime = client.getTickCount(); } return; } @@ -310,6 +313,7 @@ public class ChatCommandsPlugin extends Plugin lastPb = -1; } lastBossKill = boss; + lastBossTime = client.getTickCount(); return; } @@ -428,7 +432,11 @@ public class ChatCommandsPlugin extends Plugin setKc("Hallowed Sepulchre", kc); } - lastBossKill = null; + if (lastBossKill != null && lastBossTime != client.getTickCount()) + { + lastBossKill = null; + lastBossTime = -1; + } } private static int timeStringToSeconds(String timeString) diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java index 0145df8777..db008b2f34 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java @@ -679,4 +679,20 @@ public class ChatCommandsPluginTest verify(configManager).setRSProfileConfiguration("killcount", "hallowed sepulchre", 36); } + + @Test + public void testJadNewPbWithLeagueTask() + { + ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your TzTok-Jad kill count is: 2.", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Congratulations, you've completed a master task: Complete the Fight Caves in 25:00.", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Duration: 21:58 (new personal best)", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + verify(configManager).setRSProfileConfiguration(eq("personalbest"), eq("tztok-jad"), eq(21 * 60 + 58)); + verify(configManager).setRSProfileConfiguration(eq("killcount"), eq("tztok-jad"), eq(2)); + } }