Merge remote-tracking branch 'runelite/master'
This commit is contained in:
@@ -94,6 +94,7 @@ 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 RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: <col=ff0000>(\\d+)</col>");
|
||||
private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete! Duration <col=ff0000>([0-9:]+)</col>");
|
||||
private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: <col=ff0000>(\\d+)</col>");
|
||||
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: ([0-9:]+)");
|
||||
@@ -452,6 +453,17 @@ public class ChatCommandsPlugin extends Plugin
|
||||
int kc = Integer.parseInt(matcher.group(2));
|
||||
|
||||
setKc(boss, kc);
|
||||
if (lastPb > -1)
|
||||
{
|
||||
// lastPb contains the last raid duration and not the personal best, because the raid
|
||||
// complete message does not include the pb. We have to check if it is a new pb:
|
||||
int currentPb = getPb(boss);
|
||||
if (currentPb <= 0 || lastPb < currentPb)
|
||||
{
|
||||
setPb(boss, lastPb);
|
||||
}
|
||||
lastPb = -1;
|
||||
}
|
||||
lastBossKill = boss;
|
||||
return;
|
||||
}
|
||||
@@ -513,29 +525,44 @@ public class ChatCommandsPlugin extends Plugin
|
||||
matchPb(matcher);
|
||||
}
|
||||
|
||||
matcher = RAIDS_DURATION_PATTERN.matcher(message);
|
||||
if (matcher.find())
|
||||
{
|
||||
matchPb(matcher);
|
||||
}
|
||||
|
||||
lastBossKill = null;
|
||||
}
|
||||
|
||||
private static int timeStringToSeconds(String timeString)
|
||||
{
|
||||
String[] s = timeString.split(":");
|
||||
if (s.length == 2) // mm:ss
|
||||
{
|
||||
return Integer.parseInt(s[0]) * 60 + Integer.parseInt(s[1]);
|
||||
}
|
||||
else if (s.length == 3) // h:mm:ss
|
||||
{
|
||||
return Integer.parseInt(s[0]) * 60 * 60 + Integer.parseInt(s[1]) * 60 + Integer.parseInt(s[2]);
|
||||
}
|
||||
return Integer.parseInt(timeString);
|
||||
}
|
||||
|
||||
private void matchPb(Matcher matcher)
|
||||
{
|
||||
String personalBest = matcher.group(1);
|
||||
String[] s = personalBest.split(":");
|
||||
if (s.length == 2)
|
||||
int seconds = timeStringToSeconds(matcher.group(1));
|
||||
if (lastBossKill != null)
|
||||
{
|
||||
int seconds = Integer.parseInt(s[0]) * 60 + Integer.parseInt(s[1]);
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -612,21 +612,17 @@ public class ClientUI
|
||||
{
|
||||
OSXUtil.requestFocus();
|
||||
}
|
||||
// The workaround for Windows is to minimise and then un-minimise the client to bring
|
||||
// it to the front because java.awt.Window#toFront doesn't work reliably.
|
||||
// See https://stackoverflow.com/questions/309023/how-to-bring-a-window-to-the-front/7435722#7435722
|
||||
else if (OSType.getOSType() == OSType.Windows && !frame.isFocused())
|
||||
{
|
||||
if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH)
|
||||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
SwingUtilities.invokeLater(() ->
|
||||
if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH)
|
||||
{
|
||||
frame.setExtendedState(JFrame.ICONIFIED);
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
SwingUtilities.invokeLater(() ->
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the client is snapped to the top and bottom edges of the screen, setExtendedState will
|
||||
// will reset it so setSize and setLocation ensure that the client doesn't move or resize.
|
||||
@@ -639,8 +635,8 @@ public class ClientUI
|
||||
frame.setExtendedState(JFrame.NORMAL);
|
||||
frame.setLocation(x, y);
|
||||
frame.setSize(width, height);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
frame.requestFocus();
|
||||
|
||||
Reference in New Issue
Block a user