Skip to content

Commit

Permalink
Auto Pest Exchange:
Browse files Browse the repository at this point in the history
= Fixed not respecting 'Trigger before contest starts (in minutes)' setting, thanks RobotHanzo!
  • Loading branch information
onixiya1337 committed Jun 22, 2024
2 parents 96af60f + a2acd80 commit 8c5b441
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ baseGroup=com.jelly.farmhelperv2
mcVersion=1.8.9
modid=farmhelperv2
modName=FarmHelper
version=2.7.4-pre1
version=2.7.4-pre2
shouldRelease=true
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,24 @@ public boolean canEnableMacro(boolean manual) {
LogUtils.sendWarning("[Auto Pest Exchange] Pest Hunter bonus is active or unknown, skipping...");
return false;
}
if (!manual && GameStateHandler.getInstance().inJacobContest() && !FarmHelperConfig.autoPestExchangeIgnoreJacobsContest) {
if (!manual && !GameStateHandler.getInstance().inJacobContest() && !FarmHelperConfig.autoPestExchangeIgnoreJacobsContest) {
LogUtils.sendDebug("[Auto Pest Exchange] Checking when Jacob's contest starts...");
for (String line : TablistUtils.getTabList()) {
Matcher matcher = GameStateHandler.getInstance().jacobsRemainingTimePattern.matcher(line);
if (matcher.find()) {
String minutes = matcher.group(1);
if (Integer.parseInt(minutes) > FarmHelperConfig.autoPestExchangeTriggerBeforeContestStarts) {
Matcher matcher = GameStateHandler.getInstance().jacobsStartsInTimePattern.matcher(line);
if (matcher.find() && matcher.groupCount() >= 1) {
float minutes = 0f;
if (line.endsWith("m")) {
minutes = Integer.parseInt(matcher.group(1));
} else if (line.endsWith("s")) {
if (matcher.groupCount() >= 2) {
minutes = Integer.parseInt(matcher.group(1));
minutes += Integer.parseInt(matcher.group(2)) / 60f;
} else {
minutes = Integer.parseInt(matcher.group(1)) / 60f;
}
}
LogUtils.sendDebug("[Auto Pest Exchange] Jacob's contest is starting in " + minutes + " minutes...");
if (minutes > FarmHelperConfig.autoPestExchangeTriggerBeforeContestStarts) {
LogUtils.sendDebug("[Auto Pest Exchange] Jacob's contest is starting in " + minutes + " minutes, skipping...");
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class GameStateHandler {
@Getter
private final Clock jacobContestLeftClock = new Clock();
public final Pattern jacobsRemainingTimePattern = Pattern.compile("([0-9]|[1-2][0-9])m([0-9]|[1-5][0-9])s");
public final Pattern jacobsStartsInTimePattern = Pattern.compile("Starts In: ([1-3]?[0-9])?m ?([1-5]?[0-9])?s?");
private final Pattern serverClosingPattern = Pattern.compile("Server closing: (?<minutes>\\d+):(?<seconds>\\d+) .*");
private final Pattern pestsFromVacuumPattern = Pattern.compile("Vacuum Bag: (\\d+) Pest(s)?");
@Getter
Expand Down

0 comments on commit 8c5b441

Please sign in to comment.