chat commands: update to parse new adv log pb counters
This commit is contained in:
@@ -69,7 +69,7 @@ import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.vars.AccountType;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID;
|
||||
import static net.runelite.api.widgets.WidgetID.GENERIC_SCROLL_GROUP_ID;
|
||||
import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID;
|
||||
import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
@@ -109,9 +109,9 @@ import org.apache.commons.text.WordUtils;
|
||||
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 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:]+(?:\\.[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:]+(?:\\.[0-9]+)?)</col>");
|
||||
private static final String 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>" + 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>");
|
||||
private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("Theatre of Blood wave completion time: <col=ff0000>(?<pb>[0-9:]+(?:\\.[0-9]+)?)</col> \\(new personal best\\)");
|
||||
private static final Pattern TOB_WAVE_DURATION_PATTERN = Pattern.compile("Theatre of Blood wave completion time: <col=ff0000>[0-9:.]+</col>\\. Personal best: (?<pb>[0-9:]+(?:\\.[0-9]+)?)");
|
||||
private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)(?:(?:Fight |Lap |Challenge |Corrupted challenge )?duration:|Subdued in) <col=[0-9a-f]{6}>[0-9:.]+</col>\\. Personal best: (?:<col=ff0000>)?(?<pb>[0-9:]+(?:\\.[0-9]+)?)");
|
||||
@@ -119,9 +119,7 @@ public class ChatCommandsPlugin extends Plugin
|
||||
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 ADVENTURE_LOG_TITLE_PATTERN = Pattern.compile("The Exploits of (.+)");
|
||||
private static final Pattern ADVENTURE_LOG_COX_PB_PATTERN = Pattern.compile("Fastest (?:kill|run)(?: - \\(Team size: " + COX_TEAM_SIZES + "\\))?: ([0-9:]+(?:\\.[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 ADVENTURE_LOG_PB_PATTERN = Pattern.compile("Fastest (?:kill|run)(?: - \\(Team size: " + TEAM_SIZES + "\\))?: ([0-9:]+(?:\\.[0-9]+)?)");
|
||||
private static final Pattern HS_PB_PATTERN = Pattern.compile("Floor (?<floor>\\d) time: <col=ff0000>(?<floortime>[0-9:]+(?:\\.[0-9]+)?)</col>(?: \\(new personal best\\)|. Personal best: (?<floorpb>[0-9:]+(?:\\.[0-9]+)?))" +
|
||||
"(?:<br>Overall time: <col=ff0000>(?<otime>[0-9:]+(?:\\.[0-9]+)?)</col>(?: \\(new personal best\\)|. Personal best: (?<opb>[0-9:]+(?:\\.[0-9]+)?)))?");
|
||||
private static final Pattern HS_KC_FLOOR_PATTERN = Pattern.compile("You have completed Floor (\\d) of the Hallowed Sepulchre! Total completions: <col=ff0000>([0-9,]+)</col>\\.");
|
||||
@@ -633,37 +631,47 @@ public class ChatCommandsPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
// Adventure log - Counters
|
||||
if (scrollInterfaceLoaded)
|
||||
{
|
||||
scrollInterfaceLoaded = false;
|
||||
|
||||
if (client.getLocalPlayer().getName().equals(pohOwner))
|
||||
{
|
||||
String counterText = Text.sanitizeMultilineText(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT).getText());
|
||||
Matcher mCounterText = ADVENTURE_LOG_PB_PATTERN.matcher(counterText);
|
||||
while (mCounterText.find())
|
||||
Widget parent = client.getWidget(WidgetInfo.DIARY_QUEST_WIDGET_TEXT);
|
||||
// Each line is a separate static child
|
||||
Widget[] children = parent.getStaticChildren();
|
||||
String[] text = Arrays.stream(children)
|
||||
.map(Widget::getText)
|
||||
.map(Text::removeTags)
|
||||
.toArray(String[]::new);
|
||||
|
||||
for (int i = 0; i < text.length; ++i)
|
||||
{
|
||||
String bossName = longBossName(mCounterText.group(1));
|
||||
if (bossName.equalsIgnoreCase("chambers of xeric") ||
|
||||
bossName.equalsIgnoreCase("chambers of xeric challenge mode"))
|
||||
String boss = longBossName(text[i]);
|
||||
double pb = Double.MAX_VALUE;
|
||||
|
||||
for (i = i + 1; i < text.length; ++i)
|
||||
{
|
||||
Matcher mCoxRuns = ADVENTURE_LOG_COX_PB_PATTERN.matcher(mCounterText.group());
|
||||
double bestPbTime = Double.MAX_VALUE;
|
||||
while (mCoxRuns.find())
|
||||
String line = text[i];
|
||||
if (line.isEmpty())
|
||||
{
|
||||
bestPbTime = Math.min(timeStringToSeconds(mCoxRuns.group(1)), bestPbTime);
|
||||
break;
|
||||
}
|
||||
// So we don't reset people's already saved PB's if they had one before the update
|
||||
double currentPb = getPb(bossName);
|
||||
if (currentPb == 0 || currentPb > bestPbTime)
|
||||
|
||||
// Some bosses have multiple pbs for each team size, just use the lowest
|
||||
Matcher matcher = ADVENTURE_LOG_PB_PATTERN.matcher(line);
|
||||
if (matcher.find())
|
||||
{
|
||||
setPb(bossName, bestPbTime);
|
||||
double s = timeStringToSeconds(matcher.group(1));
|
||||
pb = Math.min(pb, s);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (pb < Double.MAX_VALUE)
|
||||
{
|
||||
String pbTime = mCounterText.group(2);
|
||||
setPb(bossName, timeStringToSeconds(pbTime));
|
||||
log.debug("Found adventure log PB for {}: {}", boss, pb);
|
||||
setPb(boss, pb);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -722,7 +730,7 @@ public class ChatCommandsPlugin extends Plugin
|
||||
case KILL_LOGS_GROUP_ID:
|
||||
bossLogLoaded = true;
|
||||
break;
|
||||
case GENERIC_SCROLL_GROUP_ID:
|
||||
case DIARY_QUEST_GROUP_ID:
|
||||
scrollInterfaceLoaded = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user