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 <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-08-20 11:28:47 +02:00
parent c61f026518
commit 274f71fe57

View File

@@ -66,8 +66,8 @@ public class IdleNotifierPlugin extends Plugin
private Actor lastOpponent; private Actor lastOpponent;
private Instant lastAnimating; private Instant lastAnimating;
private int lastAnimation = AnimationID.IDLE;
private Instant lastInteracting; private Instant lastInteracting;
private boolean notifyIdle = false;
private boolean notifyHitpoints = true; private boolean notifyHitpoints = true;
private boolean notifyPrayer = true; private boolean notifyPrayer = true;
private boolean notifyIdleLogout = true; private boolean notifyIdleLogout = true;
@@ -192,8 +192,13 @@ public class IdleNotifierPlugin extends Plugin
/* Prayer */ /* Prayer */
case USING_GILDED_ALTAR: case USING_GILDED_ALTAR:
resetTimers(); resetTimers();
notifyIdle = true; lastAnimation = animation;
break; 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) 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) lastAnimation = IDLE;
{ lastAnimating = null;
notifyIdle = false; return true;
lastAnimating = null;
return true;
}
}
else if (local.getAnimation() == IDLE)
{
lastAnimating = Instant.now();
} }
} }
else
{
lastAnimating = Instant.now();
}
return false; return false;
} }
private void resetTimers() private void resetTimers()
{ {
final Player local = client.getLocalPlayer();
// Reset animation idle timer // Reset animation idle timer
notifyIdle = false;
lastAnimating = null; lastAnimating = null;
if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getAnimation() != lastAnimation)
{
lastAnimation = IDLE;
}
// Reset combat idle timer // Reset combat idle timer
lastOpponent = null; lastOpponent = null;