From 274f71fe57c45e52fc6013dd2f36185fcabafc01 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Mon, 20 Aug 2018 11:28:47 +0200 Subject: [PATCH] Make animation idle remember last animating ID In order to make animation idle notifier work with timer resetting, make it remember last animation. Signed-off-by: Tomas Slusny --- .../idlenotifier/IdleNotifierPlugin.java | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java index 6e4fc12b14..df49a4ccff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java @@ -66,8 +66,8 @@ public class IdleNotifierPlugin extends Plugin private Actor lastOpponent; private Instant lastAnimating; + private int lastAnimation = AnimationID.IDLE; private Instant lastInteracting; - private boolean notifyIdle = false; private boolean notifyHitpoints = true; private boolean notifyPrayer = true; private boolean notifyIdleLogout = true; @@ -192,8 +192,13 @@ public class IdleNotifierPlugin extends Plugin /* Prayer */ case USING_GILDED_ALTAR: resetTimers(); - notifyIdle = true; + lastAnimation = animation; break; + case IDLE: + break; + default: + // On unknown animation simply assume the animation is invalid and dont throw notification + lastAnimation = IDLE; } } @@ -394,31 +399,40 @@ public class IdleNotifierPlugin extends Plugin private boolean checkAnimationIdle(Duration waitDuration, Player local) { - if (notifyIdle) + if (lastAnimation == IDLE) { - if (lastAnimating != null) + return false; + } + + final int animation = local.getAnimation(); + + if (animation == IDLE) + { + if (lastAnimating != null && Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0) { - if (Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0) - { - notifyIdle = false; - lastAnimating = null; - return true; - } - } - else if (local.getAnimation() == IDLE) - { - lastAnimating = Instant.now(); + lastAnimation = IDLE; + lastAnimating = null; + return true; } } + else + { + lastAnimating = Instant.now(); + } return false; } private void resetTimers() { + final Player local = client.getLocalPlayer(); + // Reset animation idle timer - notifyIdle = false; lastAnimating = null; + if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getAnimation() != lastAnimation) + { + lastAnimation = IDLE; + } // Reset combat idle timer lastOpponent = null;