chat commands: add jad challenge kc and pbs
This commit is contained in:
@@ -27,10 +27,12 @@ package net.runelite.client.plugins.chatcommands;
|
|||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -91,16 +93,13 @@ import org.apache.commons.text.WordUtils;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ChatCommandsPlugin extends Plugin
|
public class ChatCommandsPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (.+) (?:kill|harvest|lap|completion) count is: <col=ff0000>(\\d+)</col>");
|
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 RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: <col=ff0000>(\\d+)</col>");
|
|
||||||
private static final String COX_TEAM_SIZES = "(?:\\d+(?:\\+|-\\d+)? players|Solo)";
|
private static final String COX_TEAM_SIZES = "(?:\\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>" + COX_TEAM_SIZES + "</col> Duration:</col> <col=ff0000>(?<pb>[0-9:]+)</col> \\(new personal best\\)</col>");
|
private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("<col=ef20ff>Congratulations - your raid is complete!</col><br>Team size: <col=ff0000>" + COX_TEAM_SIZES + "</col> Duration:</col> <col=ff0000>(?<pb>[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>" + COX_TEAM_SIZES + "</col> Duration:</col> <col=ff0000>[0-9:]+</col> Personal best: </col><col=ff0000>(?<pb>[0-9:]+)</col>");
|
private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("<col=ef20ff>Congratulations - your raid is complete!</col><br>Team size: <col=ff0000>" + COX_TEAM_SIZES + "</col> Duration:</col> <col=ff0000>[0-9:]+</col> Personal best: </col><col=ff0000>(?<pb>[0-9:]+)</col>");
|
||||||
private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: <col=ff0000>(?<pb>[0-9:]+)</col> \\(Personal best!\\)");
|
private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: <col=ff0000>(?<pb>[0-9:]+)</col> \\(Personal best!\\)");
|
||||||
private static final Pattern TOB_WAVE_DURATION_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: <col=ff0000>[0-9:]+</col><br></col>Personal best: (?<pb>[0-9:]+)");
|
private static final Pattern TOB_WAVE_DURATION_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: <col=ff0000>[0-9:]+</col><br></col>Personal best: (?<pb>[0-9:]+)");
|
||||||
private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: <col=ff0000>(\\d+)</col>");
|
private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: <col=ff0000>[0-9:]+</col>\\. Personal best: (?:<col=ff0000>)?(?<pb>[0-9:]+)");
|
||||||
private static final Pattern BARROWS_PATTERN = Pattern.compile("Your Barrows chest count is: <col=ff0000>(\\d+)</col>");
|
|
||||||
private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: <col=ff0000>[0-9:]+</col>\\. Personal best: (?<pb>[0-9:]+)");
|
|
||||||
private static final Pattern NEW_PB_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: <col=ff0000>(?<pb>[0-9:]+)</col> \\(new personal best\\)");
|
private static final Pattern NEW_PB_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: <col=ff0000>(?<pb>[0-9:]+)</col> \\(new personal best\\)");
|
||||||
private static final Pattern DUEL_ARENA_WINS_PATTERN = Pattern.compile("You (were defeated|won)! You have(?: now)? won (\\d+) duels?");
|
private static final Pattern DUEL_ARENA_WINS_PATTERN = Pattern.compile("You (were defeated|won)! You have(?: now)? won (\\d+) duels?");
|
||||||
private static final Pattern DUEL_ARENA_LOSSES_PATTERN = Pattern.compile("You have(?: now)? lost (\\d+) duels?");
|
private static final Pattern DUEL_ARENA_LOSSES_PATTERN = Pattern.compile("You have(?: now)? lost (\\d+) duels?");
|
||||||
@@ -132,6 +131,10 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int ADV_LOG_EXPLOITS_TEXT_INDEX = 1;
|
static final int ADV_LOG_EXPLOITS_TEXT_INDEX = 1;
|
||||||
|
|
||||||
|
private static final Map<String, String> KILLCOUNT_RENAMES = ImmutableMap.of(
|
||||||
|
"Barrows chest", "Barrows Chests"
|
||||||
|
);
|
||||||
|
|
||||||
private boolean bossLogLoaded;
|
private boolean bossLogLoaded;
|
||||||
private boolean advLogLoaded;
|
private boolean advLogLoaded;
|
||||||
private boolean scrollInterfaceLoaded;
|
private boolean scrollInterfaceLoaded;
|
||||||
@@ -273,6 +276,8 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
String boss = matcher.group(1);
|
String boss = matcher.group(1);
|
||||||
int kc = Integer.parseInt(matcher.group(2));
|
int kc = Integer.parseInt(matcher.group(2));
|
||||||
|
|
||||||
|
boss = KILLCOUNT_RENAMES.getOrDefault(boss, boss);
|
||||||
|
|
||||||
setKc(boss, kc);
|
setKc(boss, kc);
|
||||||
// We either already have the pb, or need to remember the boss for the upcoming pb
|
// We either already have the pb, or need to remember the boss for the upcoming pb
|
||||||
if (lastPb > -1)
|
if (lastPb > -1)
|
||||||
@@ -289,31 +294,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
matcher = WINTERTODT_PATTERN.matcher(message);
|
|
||||||
if (matcher.find())
|
|
||||||
{
|
|
||||||
int kc = Integer.parseInt(matcher.group(1));
|
|
||||||
|
|
||||||
setKc("Wintertodt", kc);
|
|
||||||
}
|
|
||||||
|
|
||||||
matcher = RAIDS_PATTERN.matcher(message);
|
|
||||||
if (matcher.find())
|
|
||||||
{
|
|
||||||
String boss = matcher.group(1);
|
|
||||||
int kc = Integer.parseInt(matcher.group(2));
|
|
||||||
|
|
||||||
setKc(boss, kc);
|
|
||||||
if (lastPb > -1)
|
|
||||||
{
|
|
||||||
setPb(boss, lastPb);
|
|
||||||
lastPb = -1;
|
|
||||||
}
|
|
||||||
lastBossKill = boss;
|
|
||||||
lastBossTime = client.getTickCount();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
matcher = DUEL_ARENA_WINS_PATTERN.matcher(message);
|
matcher = DUEL_ARENA_WINS_PATTERN.matcher(message);
|
||||||
if (matcher.find())
|
if (matcher.find())
|
||||||
{
|
{
|
||||||
@@ -351,14 +331,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
setKc("Duel Arena Losses", losses);
|
setKc("Duel Arena Losses", losses);
|
||||||
}
|
}
|
||||||
|
|
||||||
matcher = BARROWS_PATTERN.matcher(message);
|
|
||||||
if (matcher.find())
|
|
||||||
{
|
|
||||||
int kc = Integer.parseInt(matcher.group(1));
|
|
||||||
|
|
||||||
setKc("Barrows Chests", kc);
|
|
||||||
}
|
|
||||||
|
|
||||||
matcher = KILL_DURATION_PATTERN.matcher(message);
|
matcher = KILL_DURATION_PATTERN.matcher(message);
|
||||||
if (matcher.find())
|
if (matcher.find())
|
||||||
{
|
{
|
||||||
@@ -1859,6 +1831,20 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
case "wildy agility":
|
case "wildy agility":
|
||||||
return "Wilderness Agility";
|
return "Wilderness Agility";
|
||||||
|
|
||||||
|
// Jad challenge
|
||||||
|
case "jad 1":
|
||||||
|
return "TzHaar-Ket-Rak's First Challenge";
|
||||||
|
case "jad 2":
|
||||||
|
return "TzHaar-Ket-Rak's Second Challenge";
|
||||||
|
case "jad 3":
|
||||||
|
return "TzHaar-Ket-Rak's Third Challenge";
|
||||||
|
case "jad 4":
|
||||||
|
return "TzHaar-Ket-Rak's Fourth Challenge";
|
||||||
|
case "jad 5":
|
||||||
|
return "TzHaar-Ket-Rak's Fifth Challenge";
|
||||||
|
case "jad 6":
|
||||||
|
return "TzHaar-Ket-Rak's Sixth Challenge";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return WordUtils.capitalize(boss);
|
return WordUtils.capitalize(boss);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -660,4 +660,30 @@ public class ChatCommandsPluginTest
|
|||||||
verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 21 * 60 + 58);
|
verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 21 * 60 + 58);
|
||||||
verify(configManager).setRSProfileConfiguration("killcount", "tztok-jad", 2);
|
verify(configManager).setRSProfileConfiguration("killcount", "tztok-jad", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJadChallengeNewPb()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completion count for TzHaar-Ket-Rak's First Challenge is: <col=ff0000>1</col>.", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
|
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Challenge duration: <col=ff0000>1:46</col> (new personal best)", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
|
verify(configManager).setRSProfileConfiguration("killcount", "TzHaar-Ket-Rak's First Challenge".toLowerCase(), 1);
|
||||||
|
verify(configManager).setRSProfileConfiguration("personalbest", "TzHaar-Ket-Rak's First Challenge".toLowerCase(), 60 + 46);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJadChallengeNoPb()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completion count for TzHaar-Ket-Rak's First Challenge is: <col=ff0000>3</col>.", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
|
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Challenge duration: <col=ff0000>1:10</col>. Personal best: <col=ff0000>0:59</col>", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
|
verify(configManager).setRSProfileConfiguration("killcount", "TzHaar-Ket-Rak's First Challenge".toLowerCase(), 3);
|
||||||
|
verify(configManager).setRSProfileConfiguration("personalbest", "TzHaar-Ket-Rak's First Challenge".toLowerCase(), 59);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user