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 67359d10ea..e0017e1d3d 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,6 +27,7 @@ package net.runelite.client.plugins.chatcommands; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; @@ -107,7 +108,7 @@ import org.apache.commons.text.WordUtils; @Slf4j public class ChatCommandsPlugin extends Plugin { - private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (?:completion count for |subdued |completed )?(.+?) (?:(?:kill|harvest|lap|completion) )?(?: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 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]+)?)"); @@ -388,8 +389,16 @@ public class ChatCommandsPlugin extends Plugin Matcher matcher = KILLCOUNT_PATTERN.matcher(message); if (matcher.find()) { - String boss = matcher.group(1); - int kc = Integer.parseInt(matcher.group(2)); + final String boss = matcher.group("boss"); + final int kc = Integer.parseInt(matcher.group("kc")); + final String pre = matcher.group("pre"); + final String post = matcher.group("post"); + + if (Strings.isNullOrEmpty(pre) && Strings.isNullOrEmpty(post)) + { + unsetKc(boss); + return; + } String renamedBoss = KILLCOUNT_RENAMES .getOrDefault(boss, 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 14b92f8b1a..08090286cd 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 @@ -66,12 +66,15 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; import org.mockito.Mock; import static org.mockito.Mockito.any; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.mockito.junit.MockitoJUnitRunner; @@ -1156,4 +1159,13 @@ public class ChatCommandsPluginTest verify(configManager).setRSProfileConfiguration("killcount", "guardians of the rift", 167); } + + @Test + public void testReward() + { + ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your reward is: 1 x Kebab.", null, 0); + chatCommandsPlugin.onChatMessage(chatMessage); + + verify(configManager, never()).setRSProfileConfiguration(anyString(), anyString(), anyInt()); + } }