From 9980c1129682c51aaac55f30415a437172a0ad06 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 28 Mar 2022 12:41:48 -0400 Subject: [PATCH] chat commands: fix tob pb tracking The word "wave" was removed from the message --- .../chatcommands/ChatCommandsPlugin.java | 18 ++-------- .../chatcommands/ChatCommandsPluginTest.java | 33 ++++++++++++++----- 2 files changed, 26 insertions(+), 25 deletions(-) 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 8a29140b61..7e41725bee 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 @@ -110,10 +110,8 @@ public class ChatCommandsPlugin extends Plugin private static final String TEAM_SIZES = "(?:\\d+(?:\\+|-\\d+)? players|Solo)"; private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + TEAM_SIZES + " Duration: (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + TEAM_SIZES + " Duration: [0-9:.]+ Personal best: (?[0-9:]+(?:\\.[0-9]+)?)"); - private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("Theatre of Blood wave completion time: (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); - private static final Pattern TOB_WAVE_DURATION_PATTERN = Pattern.compile("Theatre of Blood wave completion time: [0-9:.]+\\. Personal best: (?[0-9:]+(?:\\.[0-9]+)?)"); - private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)(?:(?:Fight |Lap |Challenge |Corrupted challenge )?duration:|Subdued in) [0-9:.]+\\. Personal best: (?:)?(?[0-9:]+(?:\\.[0-9]+)?)"); - private static final Pattern NEW_PB_PATTERN = Pattern.compile("(?i)(?:(?:Fight |Lap |Challenge |Corrupted challenge )?duration:|Subdued in) (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); + private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)(?:(?:Fight |Lap |Challenge |Corrupted challenge )?duration:|Subdued in|(?[0-9:.]+\\. Personal best: (?:)?(?[0-9:]+(?:\\.[0-9]+)?)"); + private static final Pattern NEW_PB_PATTERN = Pattern.compile("(?i)(?:(?:Fight |Lap |Challenge |Corrupted challenge )?duration:|Subdued in|(?(?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); private static final Pattern DUEL_ARENA_WINS_PATTERN = Pattern.compile("You (were defeated|won)! You have(?: now)? won ([\\d,]+|one) duels?"); private static final Pattern DUEL_ARENA_LOSSES_PATTERN = Pattern.compile("You have(?: now)? lost ([\\d,]+|one) duels?"); private static final Pattern ADVENTURE_LOG_TITLE_PATTERN = Pattern.compile("The Exploits of (.+)"); @@ -470,18 +468,6 @@ public class ChatCommandsPlugin extends Plugin matchPb(matcher); } - matcher = TOB_WAVE_PB_PATTERN.matcher(message); - if (matcher.find()) - { - matchPb(matcher); - } - - matcher = TOB_WAVE_DURATION_PATTERN.matcher(message); - if (matcher.find()) - { - matchPb(matcher); - } - matcher = HS_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 e95a3fc267..a928a5709a 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 @@ -165,11 +165,16 @@ public class ChatCommandsPluginTest public void testTheatreOfBlood() { ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", - "Wave 'The Final Challenge' (Normal Mode) complete!
Duration: 2:42.0
Theatre of Blood wave completion time: 17:00.20 (new personal best)", null, 0); + "Wave 'The Final Challenge' (Normal Mode) complete!
" + + "Duration: 2:42.0
" + + "Theatre of Blood completion time: 17:00.20 (new personal best)", null, 0); chatCommandsPlugin.onChatMessage(chatMessage); - ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: 73.", null, 0); - chatCommandsPlugin.onChatMessage(chatMessageEvent); + chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Theatre of Blood total completion time: 24:40.20. Personal best: 20:45.00", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: 73.", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration("killcount", "theatre of blood", 73); verify(configManager).setRSProfileConfiguration("personalbest", "theatre of blood", 17 * 60 + .2); @@ -179,11 +184,16 @@ public class ChatCommandsPluginTest public void testTheatreOfBloodNoPb() { ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", - "Wave 'The Final Challenge' (Normal Mode) complete!
Duration: 2:42
Theatre of Blood wave completion time: 17:00. Personal best: 13:52.80", null, 0); + "Wave 'The Final Challenge' (Normal Mode) complete!
" + + "Duration: 2:42
" + + "Theatre of Blood completion time: 17:00. Personal best: 13:52.80", null, 0); chatCommandsPlugin.onChatMessage(chatMessage); - ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: 73.", null, 0); - chatCommandsPlugin.onChatMessage(chatMessageEvent); + chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Theatre of Blood total completion time: 24:40.20. Personal best: 20:45.00", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: 73.", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration("killcount", "theatre of blood", 73); verify(configManager).setRSProfileConfiguration("personalbest", "theatre of blood", 13 * 60 + 52.8); @@ -193,11 +203,16 @@ public class ChatCommandsPluginTest public void testTheatreOfBloodEntryMode() { ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", - "Wave 'The Final Challenge' (Entry Mode) complete!
Duration: 2:42
Theatre of Blood wave completion time: 17:00 (new personal best)", null, 0); + "Wave 'The Final Challenge' (Entry Mode) complete!
" + + "Duration: 2:42
" + + "Theatre of Blood completion time: 17:00 (new personal best)", null, 0); chatCommandsPlugin.onChatMessage(chatMessage); - ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood: Entry Mode count is: 73.", null, 0); - chatCommandsPlugin.onChatMessage(chatMessageEvent); + chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Theatre of Blood total completion time: 24:40.20. Personal best: 20:45.00", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood: Entry Mode count is: 73.", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration("killcount", "theatre of blood entry mode", 73); verify(configManager).setRSProfileConfiguration("personalbest", "theatre of blood entry mode", 17 * 60.);