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 7d877cb7aa..4d7bac6c1e 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
@@ -27,10 +27,12 @@ package net.runelite.client.plugins.chatcommands;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableMap;
import com.google.inject.Provides;
import java.io.IOException;
import java.util.EnumSet;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -91,16 +93,13 @@ import org.apache.commons.text.WordUtils;
@Slf4j
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 KILLCOUNT_PATTERN = Pattern.compile("Your (?:completion count for |subdued |completed )?(.+?) (?:(?:kill|harvest|lap|completion) )?(?:count )?is: (\\d+)");
private static final String COX_TEAM_SIZES = "(?:\\d+(?:\\+|-\\d+)? players|Solo)";
private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + COX_TEAM_SIZES + " Duration: (?[0-9:]+) \\(new personal best\\)");
private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + COX_TEAM_SIZES + " 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+)");
- private static final Pattern BARROWS_PATTERN = Pattern.compile("Your Barrows chest count is: (\\d+)");
- private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: [0-9:]+\\. Personal best: (?[0-9:]+)");
+ private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: [0-9:]+\\. Personal best: (?:)?(?[0-9:]+)");
private static final Pattern NEW_PB_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: (?[0-9:]+) \\(new personal best\\)");
private static final Pattern DUEL_ARENA_WINS_PATTERN = Pattern.compile("You (were defeated|won)! You have(?: now)? won (\\d+) duels?");
private static final Pattern DUEL_ARENA_LOSSES_PATTERN = Pattern.compile("You have(?: now)? lost (\\d+) duels?");
@@ -132,6 +131,10 @@ public class ChatCommandsPlugin extends Plugin
@VisibleForTesting
static final int ADV_LOG_EXPLOITS_TEXT_INDEX = 1;
+ private static final Map KILLCOUNT_RENAMES = ImmutableMap.of(
+ "Barrows chest", "Barrows Chests"
+ );
+
private boolean bossLogLoaded;
private boolean advLogLoaded;
private boolean scrollInterfaceLoaded;
@@ -273,6 +276,8 @@ public class ChatCommandsPlugin extends Plugin
String boss = matcher.group(1);
int kc = Integer.parseInt(matcher.group(2));
+ boss = KILLCOUNT_RENAMES.getOrDefault(boss, boss);
+
setKc(boss, kc);
// We either already have the pb, or need to remember the boss for the upcoming pb
if (lastPb > -1)
@@ -289,31 +294,6 @@ public class ChatCommandsPlugin extends Plugin
return;
}
- matcher = WINTERTODT_PATTERN.matcher(message);
- if (matcher.find())
- {
- int kc = Integer.parseInt(matcher.group(1));
-
- setKc("Wintertodt", kc);
- }
-
- matcher = RAIDS_PATTERN.matcher(message);
- if (matcher.find())
- {
- String boss = matcher.group(1);
- int kc = Integer.parseInt(matcher.group(2));
-
- setKc(boss, kc);
- if (lastPb > -1)
- {
- setPb(boss, lastPb);
- lastPb = -1;
- }
- lastBossKill = boss;
- lastBossTime = client.getTickCount();
- return;
- }
-
matcher = DUEL_ARENA_WINS_PATTERN.matcher(message);
if (matcher.find())
{
@@ -351,14 +331,6 @@ public class ChatCommandsPlugin extends Plugin
setKc("Duel Arena Losses", losses);
}
- matcher = BARROWS_PATTERN.matcher(message);
- if (matcher.find())
- {
- int kc = Integer.parseInt(matcher.group(1));
-
- setKc("Barrows Chests", kc);
- }
-
matcher = KILL_DURATION_PATTERN.matcher(message);
if (matcher.find())
{
@@ -1859,6 +1831,20 @@ public class ChatCommandsPlugin extends Plugin
case "wildy agility":
return "Wilderness Agility";
+ // Jad challenge
+ case "jad 1":
+ return "TzHaar-Ket-Rak's First Challenge";
+ case "jad 2":
+ return "TzHaar-Ket-Rak's Second Challenge";
+ case "jad 3":
+ return "TzHaar-Ket-Rak's Third Challenge";
+ case "jad 4":
+ return "TzHaar-Ket-Rak's Fourth Challenge";
+ case "jad 5":
+ return "TzHaar-Ket-Rak's Fifth Challenge";
+ case "jad 6":
+ return "TzHaar-Ket-Rak's Sixth Challenge";
+
default:
return WordUtils.capitalize(boss);
}
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 9df5ff5891..969bc8edf6 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
@@ -660,4 +660,30 @@ public class ChatCommandsPluginTest
verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 21 * 60 + 58);
verify(configManager).setRSProfileConfiguration("killcount", "tztok-jad", 2);
}
+
+ @Test
+ public void testJadChallengeNewPb()
+ {
+ ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completion count for TzHaar-Ket-Rak's First Challenge is: 1.", null, 0);
+ chatCommandsPlugin.onChatMessage(chatMessage);
+
+ chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Challenge duration: 1:46 (new personal best)", null, 0);
+ chatCommandsPlugin.onChatMessage(chatMessage);
+
+ verify(configManager).setRSProfileConfiguration("killcount", "TzHaar-Ket-Rak's First Challenge".toLowerCase(), 1);
+ verify(configManager).setRSProfileConfiguration("personalbest", "TzHaar-Ket-Rak's First Challenge".toLowerCase(), 60 + 46);
+ }
+
+ @Test
+ public void testJadChallengeNoPb()
+ {
+ ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completion count for TzHaar-Ket-Rak's First Challenge is: 3.", null, 0);
+ chatCommandsPlugin.onChatMessage(chatMessage);
+
+ chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Challenge duration: 1:10. Personal best: 0:59", null, 0);
+ chatCommandsPlugin.onChatMessage(chatMessage);
+
+ verify(configManager).setRSProfileConfiguration("killcount", "TzHaar-Ket-Rak's First Challenge".toLowerCase(), 3);
+ verify(configManager).setRSProfileConfiguration("personalbest", "TzHaar-Ket-Rak's First Challenge".toLowerCase(), 59);
+ }
}