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
This commit is contained in:
Adam
2020-12-04 15:50:21 -05:00
parent f5a76e9961
commit 3771444b7f
2 changed files with 25 additions and 1 deletions

View File

@@ -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)

View File

@@ -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: <col=ff0000>2</col>.", null, 0);
chatCommandsPlugin.onChatMessage(chatMessage);
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Congratulations, you've completed a master task: <col=7f3700>Complete the Fight Caves in 25:00</col>.", null, 0);
chatCommandsPlugin.onChatMessage(chatMessage);
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Duration: <col=ff0000>21:58</col> (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));
}
}