slayer plugin: fix parsing points and streaks with commas

This commit is contained in:
Adam
2018-07-13 08:33:05 -04:00
parent 70059a9bf1
commit e2b9d0b00a
2 changed files with 35 additions and 5 deletions

View File

@@ -78,7 +78,7 @@ public class SlayerPlugin extends Plugin
//Chat messages
private static final Pattern CHAT_GEM_PROGRESS_MESSAGE = Pattern.compile("You're assigned to kill (.*); only (\\d*) more to go\\.");
private static final String CHAT_GEM_COMPLETE_MESSAGE = "You need something new to hunt.";
private static final Pattern CHAT_COMPLETE_MESSAGE = Pattern.compile("[\\d]+(?:,[\\d]+)?");
private static final Pattern CHAT_COMPLETE_MESSAGE = Pattern.compile("(?:\\d+,)*\\d+");
private static final String CHAT_CANCEL_MESSAGE = "Your task has been cancelled.";
private static final String CHAT_CANCEL_MESSAGE_JAD = "You no longer have a slayer task as you left the fight cave.";
private static final String CHAT_SUPERIOR_MESSAGE = "A superior foe has appeared...";
@@ -96,7 +96,7 @@ public class SlayerPlugin extends Plugin
private static final Pattern NPC_CURRENT_MESSAGE = Pattern.compile("You're still hunting (.*); you have (\\d*) to go\\..*");
//Reward UI
private static final Pattern REWARD_POINTS = Pattern.compile("Reward points: (\\d*)");
private static final Pattern REWARD_POINTS = Pattern.compile("Reward points: ((?:\\d+,)*\\d+)");
private static final int EXPEDITIOUS_CHARGE = 30;
private static final int SLAUGHTER_CHARGE = 30;
@@ -297,7 +297,7 @@ public class SlayerPlugin extends Plugin
Matcher mPoints = REWARD_POINTS.matcher(w.getText());
if (mPoints.find())
{
points = Integer.parseInt(mPoints.group(1));
points = Integer.parseInt(mPoints.group(1).replaceAll(",", ""));
break;
}
}
@@ -374,7 +374,7 @@ public class SlayerPlugin extends Plugin
List<String> matches = new ArrayList<>();
while (mComplete.find())
{
matches.add(mComplete.group(0));
matches.add(mComplete.group(0).replaceAll(",", ""));
}
switch (matches.size())
@@ -387,7 +387,7 @@ public class SlayerPlugin extends Plugin
break;
case 3:
streak = Integer.parseInt(matches.get(0));
points = Integer.parseInt(matches.get(2).replaceAll(",", ""));
points = Integer.parseInt(matches.get(2));
break;
default:
log.warn("Unreachable default case for message ending in '; return to Slayer master'");