Properly update last action times in Idle Notifier

- Properly update last action times in Idle Notifier right after the
action is changed/updated.
- Do not reset lastCombatCountdown in resetTimers()

Supersedes/closes #6241
Extracted from #5369

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-10-29 10:11:36 +01:00
parent 62cbc776da
commit 6515174e18
2 changed files with 9 additions and 4 deletions

View File

@@ -214,19 +214,23 @@ public class IdleNotifierPlugin extends Plugin
case SAND_COLLECTION: case SAND_COLLECTION:
resetTimers(); resetTimers();
lastAnimation = animation; lastAnimation = animation;
lastAnimating = Instant.now();
break; break;
case MAGIC_LUNAR_SHARED: case MAGIC_LUNAR_SHARED:
if (graphic == GraphicID.BAKE_PIE) if (graphic == GraphicID.BAKE_PIE)
{ {
resetTimers(); resetTimers();
lastAnimation = animation; lastAnimation = animation;
lastAnimating = Instant.now();
break; break;
} }
case IDLE: case IDLE:
lastAnimating = Instant.now();
break; break;
default: default:
// On unknown animation simply assume the animation is invalid and dont throw notification // On unknown animation simply assume the animation is invalid and dont throw notification
lastAnimation = IDLE; lastAnimation = IDLE;
lastAnimating = null;
} }
} }
@@ -246,6 +250,10 @@ public class IdleNotifierPlugin extends Plugin
{ {
lastInteract = null; lastInteract = null;
} }
else
{
lastInteracting = Instant.now();
}
final boolean isNpc = target instanceof NPC; final boolean isNpc = target instanceof NPC;
@@ -264,6 +272,7 @@ public class IdleNotifierPlugin extends Plugin
// Player is most likely in combat with attack-able NPC // Player is most likely in combat with attack-able NPC
resetTimers(); resetTimers();
lastInteract = target; lastInteract = target;
lastInteracting = Instant.now();
} }
} }
@@ -553,9 +562,6 @@ public class IdleNotifierPlugin extends Plugin
{ {
final Player local = client.getLocalPlayer(); final Player local = client.getLocalPlayer();
// Reset combat idle timer
lastCombatCountdown = 0;
// Reset animation idle timer // Reset animation idle timer
lastAnimating = null; lastAnimating = null;
if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getAnimation() != lastAnimation) if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getAnimation() != lastAnimation)

View File

@@ -155,7 +155,6 @@ public class IdleNotifierPluginTest
AnimationChanged animationChanged = new AnimationChanged(); AnimationChanged animationChanged = new AnimationChanged();
animationChanged.setActor(player); animationChanged.setActor(player);
plugin.onAnimationChanged(animationChanged); plugin.onAnimationChanged(animationChanged);
plugin.onInteractingChanged(new InteractingChanged(player, monster));
plugin.onGameTick(new GameTick()); plugin.onGameTick(new GameTick());
// Logout // Logout