chat commands: add gg pb

This commit is contained in:
Adam
2019-07-30 19:37:13 -04:00
parent 1ce2e5aa93
commit 1b2219374f
2 changed files with 63 additions and 14 deletions

View File

@@ -109,6 +109,7 @@ public class ChatCommandsPlugin extends Plugin
private boolean logKills;
private HiscoreEndpoint hiscoreEndpoint; // hiscore endpoint for current player
private String lastBossKill;
private int lastPb = -1;
@Inject
private Client client;
@@ -223,7 +224,17 @@ public class ChatCommandsPlugin extends Plugin
int kc = Integer.parseInt(matcher.group(2));
setKc(boss, kc);
lastBossKill = boss;
// We either already have the pb, or need to remember the boss for the upcoming pb
if (lastPb > -1)
{
log.debug("Got out-of-order personal best for {}: {}", boss, lastPb);
setPb(boss, lastPb);
lastPb = -1;
}
else
{
lastBossKill = boss;
}
return;
}
@@ -291,19 +302,16 @@ public class ChatCommandsPlugin extends Plugin
setKc("Barrows Chests", kc);
}
if (lastBossKill != null)
matcher = KILL_DURATION_PATTERN.matcher(message);
if (matcher.find())
{
matcher = KILL_DURATION_PATTERN.matcher(message);
if (matcher.find())
{
matchPb(matcher);
}
matchPb(matcher);
}
matcher = NEW_PB_PATTERN.matcher(message);
if (matcher.find())
{
matchPb(matcher);
}
matcher = NEW_PB_PATTERN.matcher(message);
if (matcher.find())
{
matchPb(matcher);
}
lastBossKill = null;
@@ -316,8 +324,19 @@ public class ChatCommandsPlugin extends Plugin
if (s.length == 2)
{
int seconds = Integer.parseInt(s[0]) * 60 + Integer.parseInt(s[1]);
log.debug("Got personal best for {}: {}", lastBossKill, seconds);
setPb(lastBossKill, seconds);
if (lastBossKill != null)
{
// Most bosses sent boss kill message, and then pb message, so we
// use the remembered lastBossKill
log.debug("Got personal best for {}: {}", lastBossKill, seconds);
setPb(lastBossKill, seconds);
lastPb = -1;
}
else
{
// Some bosses send the pb message, and then the kill message!
lastPb = seconds;
}
}
}