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 2bc4aad635..93daedf8be 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 @@ -26,6 +26,7 @@ package net.runelite.client.plugins.chatcommands; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.MoreObjects; import com.google.inject.Provides; import java.io.IOException; import java.util.EnumSet; @@ -105,6 +106,8 @@ public class ChatCommandsPlugin extends Plugin private static final Pattern ADVENTURE_LOG_COX_PB_PATTERN = Pattern.compile("Fastest (?:kill|run)(?: - \\(Team size: (?:[0-9]+ players|Solo)\\))?: ([0-9:]+)"); private static final Pattern ADVENTURE_LOG_BOSS_PB_PATTERN = Pattern.compile("[a-zA-Z]+(?: [a-zA-Z]+)*"); private static final Pattern ADVENTURE_LOG_PB_PATTERN = Pattern.compile("(" + ADVENTURE_LOG_BOSS_PB_PATTERN + "(?: - " + ADVENTURE_LOG_BOSS_PB_PATTERN + ")*) (?:" + ADVENTURE_LOG_COX_PB_PATTERN + "( )*)+"); + private static final Pattern HS_PB_PATTERN = Pattern.compile("Floor (?\\d) time: (?[0-9:]+)(?: \\(new personal best\\)|. Personal best: (?[0-9:]+))" + + "(?:
Overall time: (?[0-9:]+)(?: \\(new personal best\\)|. Personal best: (?[0-9:]+)))?"); private static final String TOTAL_LEVEL_COMMAND_STRING = "!total"; private static final String PRICE_COMMAND_STRING = "!price"; @@ -372,6 +375,25 @@ public class ChatCommandsPlugin extends Plugin matchPb(matcher); } + matcher = HS_PB_PATTERN.matcher(message); + if (matcher.find()) + { + int floor = Integer.parseInt(matcher.group("floor")); + String floortime = matcher.group("floortime"); + String floorpb = matcher.group("floorpb"); + String otime = matcher.group("otime"); + String opb = matcher.group("opb"); + + String pb = MoreObjects.firstNonNull(floorpb, floortime); + setPb("Hallowed Sepulchre Floor " + floor, timeStringToSeconds(pb)); + + if (otime != null) + { + pb = MoreObjects.firstNonNull(opb, otime); + setPb("Hallowed Sepulchre", timeStringToSeconds(pb)); + } + } + lastBossKill = null; } @@ -1622,6 +1644,26 @@ public class ChatCommandsPlugin extends Plugin case "the nightmare": return "Nightmare"; + // Hallowed Sepulchre + case "hs": + case "sepulchre": + return "Hallowed Sepulchre"; + case "hs1": + case "hs 1": + return "Hallowed Sepulchre Floor 1"; + case "hs2": + case "hs 2": + return "Hallowed Sepulchre Floor 2"; + case "hs3": + case "hs 3": + return "Hallowed Sepulchre Floor 3"; + case "hs4": + case "hs 4": + return "Hallowed Sepulchre Floor 4"; + case "hs5": + case "hs 5": + return "Hallowed Sepulchre Floor 5"; + 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 2f64ca267e..0ecf43b2d3 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 @@ -590,4 +590,62 @@ public class ChatCommandsPluginTest verify(messageNode).setRuneLiteFormatMessage("Level Zulrah: 1000 Rank: 10"); } + + @Test + public void testHsFloorNoPb() + { + ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Floor 1 time: 1:19. Personal best: 0:28", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre floor 1", 28); + } + + @Test + public void testHsFloorPb() + { + ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Floor 2 time: 0:47 (new personal best)", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre floor 2", 47); + } + + @Test + public void testHsOverallPb_Pb() + { + ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Floor 5 time: 4:46 (new personal best)
Overall time: 9:53 (new personal best)
", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre floor 5", 4 * 60 + 46); + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre", 9 * 60 + 53); + } + + @Test + public void testHsOverallPb_NoPb() + { + ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Floor 5 time: 3:26 (new personal best)
Overall time: 9:17. Personal best: 9:15
", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre floor 5", 3 * 60 + 26); + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre", 9 * 60 + 15); + } + + @Test + public void testHsOverallNoPb_NoPb() + { + ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Floor 5 time: 3:56. Personal best: 3:05
Overall time: 9:14. Personal best: 7:49
", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre floor 5", 3 * 60 + 5); + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre", 7 * 60 + 49); + } + + @Test + public void testHsOverallNoPb_Pb() + { + ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Floor 5 time: 3:10. Personal best: 3:04
Overall time: 7:47 (new personal best)
", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre floor 5", 3 * 60 + 4); + verify(configManager).setConfiguration("personalbest.adam", "hallowed sepulchre", 7 * 60 + 47); + } }