Merge pull request #9975 from Nightfirecat/fix-woodcutting-overlay-for-long-chop-delays
Fix woodcutting overlay hiding during long chop delays
This commit is contained in:
@@ -52,6 +52,7 @@ import static net.runelite.api.ItemID.MITHRIL_AXE;
|
|||||||
import static net.runelite.api.ItemID.RUNE_AXE;
|
import static net.runelite.api.ItemID.RUNE_AXE;
|
||||||
import static net.runelite.api.ItemID.STEEL_AXE;
|
import static net.runelite.api.ItemID.STEEL_AXE;
|
||||||
import static net.runelite.api.ItemID._3RD_AGE_AXE;
|
import static net.runelite.api.ItemID._3RD_AGE_AXE;
|
||||||
|
import net.runelite.api.Player;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@@ -87,6 +88,11 @@ enum Axe
|
|||||||
AXE_ANIM_IDS = builder.build();
|
AXE_ANIM_IDS = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean matchesChoppingAnimation(final Player player)
|
||||||
|
{
|
||||||
|
return player != null && animId == player.getAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
static Axe findAxeByAnimId(int animId)
|
static Axe findAxeByAnimId(int animId)
|
||||||
{
|
{
|
||||||
return AXE_ANIM_IDS.get(animId);
|
return AXE_ANIM_IDS.get(animId);
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class WoodcuttingOverlay extends Overlay
|
|||||||
panelComponent.getChildren().clear();
|
panelComponent.getChildren().clear();
|
||||||
|
|
||||||
Axe axe = plugin.getAxe();
|
Axe axe = plugin.getAxe();
|
||||||
if (axe != null && axe.getAnimId() == client.getLocalPlayer().getAnimation())
|
if (axe != null && axe.matchesChoppingAnimation(client.getLocalPlayer()))
|
||||||
{
|
{
|
||||||
panelComponent.getChildren().add(TitleComponent.builder()
|
panelComponent.getChildren().add(TitleComponent.builder()
|
||||||
.text("Woodcutting")
|
.text("Woodcutting")
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -92,9 +93,11 @@ public class WoodcuttingPlugin extends Plugin
|
|||||||
private WoodcuttingConfig config;
|
private WoodcuttingConfig config;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@Nullable
|
||||||
private WoodcuttingSession session;
|
private WoodcuttingSession session;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@Nullable
|
||||||
private Axe axe;
|
private Axe axe;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -149,13 +152,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)
|
||||||
{
|
{
|
||||||
@@ -176,7 +185,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())
|
||||||
|
|||||||
@@ -26,17 +26,17 @@ package net.runelite.client.plugins.woodcutting;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
public class WoodcuttingSession
|
class WoodcuttingSession
|
||||||
{
|
{
|
||||||
private Instant lastLogCut;
|
private Instant lastChopping;
|
||||||
|
|
||||||
public void setLastLogCut()
|
void setLastChopping()
|
||||||
{
|
{
|
||||||
lastLogCut = Instant.now();
|
lastChopping = Instant.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getLastLogCut()
|
Instant getLastChopping()
|
||||||
{
|
{
|
||||||
return lastLogCut;
|
return lastChopping;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user