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:
@@ -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())
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user