chat commands: fix matching random event rewards as kill messages
This commit is contained in:
@@ -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: <col=ff0000>(\\d+)</col>");
|
||||
private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (?<pre>completion count for |subdued |completed )?(?<boss>.+?) (?<post>(?:(?:kill|harvest|lap|completion) )?(?:count )?)is: <col=ff0000>(?<kc>\\d+)</col>");
|
||||
private static final String TEAM_SIZES = "(?<teamsize>\\d+(?:\\+|-\\d+)? players?|Solo)";
|
||||
private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("<col=ef20ff>Congratulations - your raid is complete!</col><br>Team size: <col=ff0000>" + TEAM_SIZES + "</col> Duration:</col> <col=ff0000>(?<pb>[0-9:]+(?:\\.[0-9]+)?)</col> \\(new personal best\\)</col>");
|
||||
private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("<col=ef20ff>Congratulations - your raid is complete!</col><br>Team size: <col=ff0000>" + TEAM_SIZES + "</col> Duration:</col> <col=ff0000>[0-9:.]+</col> Personal best: </col><col=ff0000>(?<pb>[0-9:]+(?:\\.[0-9]+)?)</col>");
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user