From a52b811af129c353bfd5436e8687d9572eb1a213 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 13 Jul 2018 18:39:22 -0400 Subject: [PATCH] chat commands: count barrows chests too --- .../plugins/chatcommands/ChatCommandsPlugin.java | 9 +++++++++ .../plugins/chatcommands/ChatCommandsPluginTest.java | 11 +++++++++++ 2 files changed, 20 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 4d3ef47fbc..b2acbf3285 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 @@ -79,6 +79,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener private static final Pattern KILLCOUNT_PATERN = Pattern.compile("Your (.+) kill count is: (\\d+)."); private static final Pattern RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: (\\d+)."); private static final Pattern WINTERTODT_PATERN = Pattern.compile("Your subdued Wintertodt count is: (\\d+)."); + private static final Pattern BARROWS_PATERN = Pattern.compile("Your Barrows chest count is: (\\d+)."); private final HiscoreClient hiscoreClient = new HiscoreClient(); private final KillCountClient killCountClient = new KillCountClient(); @@ -248,6 +249,14 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener setKc(boss, kc); } + + matcher = BARROWS_PATERN.matcher(message); + if (matcher.find()) + { + int kc = Integer.parseInt(matcher.group(1)); + + setKc("Barrows", kc); + } } @Override 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 ace03ecac4..7c33d1a20b 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 @@ -117,4 +117,15 @@ public class ChatCommandsPluginTest verify(configManager).setConfiguration("killcount.adam", "kree'arra", 4); } + + @Test + public void testBarrows() + { + when(client.getUsername()).thenReturn("Adam"); + + ChatMessage chatMessageEvent = new ChatMessage(SERVER, "", "Your Barrows chest count is: 277.", null); + chatCommandsPlugin.onChatMessage(chatMessageEvent); + + verify(configManager).setConfiguration("killcount.adam", "barrows", 277); + } } \ No newline at end of file