woodcutting: Fix overlay hiding during long chop delays

This fixes a bug where the overlay would become hidden when chopping at
a tree without successfully chopping a log for longer than the
configured timeout, and would display "NOT woodcutting" if a log was
successfully chopped thereafter.

Fixes runelite/runelite#7506
This commit is contained in:
Jordan Atwood
2019-10-04 08:12:55 -07:00
parent 8a206e8c92
commit dd771eaab7
2 changed files with 14 additions and 8 deletions

View File

@@ -148,13 +148,19 @@ public class WoodcuttingPlugin extends Plugin
respawns.removeIf(TreeRespawn::isExpired); respawns.removeIf(TreeRespawn::isExpired);
if (session == null || session.getLastLogCut() == null) if (session == null || session.getLastChopping() == null)
{ {
return; return;
} }
if (axe != null && axe.matchesChoppingAnimation(client.getLocalPlayer()))
{
session.setLastChopping();
return;
}
Duration statTimeout = Duration.ofMinutes(config.statTimeout()); Duration statTimeout = Duration.ofMinutes(config.statTimeout());
Duration sinceCut = Duration.between(session.getLastLogCut(), Instant.now()); Duration sinceCut = Duration.between(session.getLastChopping(), Instant.now());
if (sinceCut.compareTo(statTimeout) >= 0) if (sinceCut.compareTo(statTimeout) >= 0)
{ {
@@ -175,7 +181,7 @@ public class WoodcuttingPlugin extends Plugin
session = new WoodcuttingSession(); session = new WoodcuttingSession();
} }
session.setLastLogCut(); session.setLastChopping();
} }
if (event.getMessage().contains("A bird's nest falls out of the tree") && config.showNestNotification()) if (event.getMessage().contains("A bird's nest falls out of the tree") && config.showNestNotification())

View File

@@ -28,15 +28,15 @@ import java.time.Instant;
class WoodcuttingSession class WoodcuttingSession
{ {
private Instant lastLogCut; private Instant lastChopping;
void setLastLogCut() void setLastChopping()
{ {
lastLogCut = Instant.now(); lastChopping = Instant.now();
} }
Instant getLastLogCut() Instant getLastChopping()
{ {
return lastLogCut; return lastChopping;
} }
} }