Merge pull request #6244 from deathbeam/idle-notifier-fixes

Properly update last action times in Idle Notifier
This commit is contained in:
Tomas Slusny
2018-11-03 12:44:30 +01:00
committed by GitHub
2 changed files with 12 additions and 5 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();
} }
} }
@@ -447,7 +456,9 @@ public class IdleNotifierPlugin extends Plugin
if (interact == null) if (interact == null)
{ {
if (lastInteracting != null && Instant.now().compareTo(lastInteracting.plus(waitDuration)) >= 0) if (lastInteracting != null
&& Instant.now().compareTo(lastInteracting.plus(waitDuration)) >= 0
&& lastCombatCountdown == 0)
{ {
lastInteract = null; lastInteract = null;
lastInteracting = null; lastInteracting = null;
@@ -553,9 +564,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