From 90aa9ecc099c3c3628bdeb8862c560b9353814f5 Mon Sep 17 00:00:00 2001
From: melkypie <5113962+melkypie@users.noreply.github.com>
Date: Sat, 6 Jun 2020 23:59:09 +0300
Subject: [PATCH] chatcommands: allow cox pb to look at previous pb times from
jagex
---
.../plugins/chatcommands/ChatCommandsPlugin.java | 7 +++++++
.../chatcommands/ChatCommandsPluginTest.java | 15 +++++++++++++++
2 files changed, 22 insertions(+)
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 5cbaec8c6a..bfe3e3479d 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
@@ -94,6 +94,7 @@ public class ChatCommandsPlugin extends Plugin
private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (.+) (?:kill|harvest|lap|completion) count is:
(\\d+)");
private static final Pattern RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: (\\d+)");
private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: (?:[0-9]+\\+? players|Solo) Duration: (?[0-9:]+) \\(new personal best\\)");
+ private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: (?:[0-9]+\\+? players|Solo) Duration: [0-9:]+ Personal best: (?[0-9:]+)");
private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: (?[0-9:]+) \\(Personal best!\\)");
private static final Pattern TOB_WAVE_DURATION_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: [0-9:]+
Personal best: (?[0-9:]+)");
private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: (\\d+)");
@@ -365,6 +366,12 @@ public class ChatCommandsPlugin extends Plugin
matchPb(matcher);
}
+ matcher = RAIDS_DURATION_PATTERN.matcher(message);
+ if (matcher.find())
+ {
+ matchPb(matcher);
+ }
+
matcher = TOB_WAVE_PB_PATTERN.matcher(message);
if (matcher.find())
{
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 8419a215af..97c40c0cc3 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
@@ -410,6 +410,21 @@ public class ChatCommandsPluginTest
verify(configManager).setConfiguration(eq("personalbest.adam"), eq("chambers of xeric"), eq(37 * 60 + 4));
}
+ @Test
+ public void testCoXKillUnknownPb()
+ {
+ when(configManager.getConfiguration("personalbest.adam", "chambers of xeric", int.class)).thenReturn(25 * 60 + 14);
+
+ ChatMessage chatMessage = new ChatMessage(null, FRIENDSCHATNOTIFICATION, "", "Congratulations - your raid is complete!
Team size: 3 players Duration: 23:25 Personal best: 20:19", null, 0);
+ chatCommandsPlugin.onChatMessage(chatMessage);
+
+ chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Chambers of Xeric count is: 52.", null, 0);
+ chatCommandsPlugin.onChatMessage(chatMessage);
+
+ verify(configManager).setConfiguration("killcount.adam", "chambers of xeric", 52);
+ verify(configManager).setConfiguration("personalbest.adam", "chambers of xeric", 20 * 60 + 19);
+ }
+
@Test
public void testCoXKillNoPb()
{