IdleNotifierPlugin extends Plugin { private boolean checkAnimationIdle(Duration waitDuration, Player local) { if (lastAnimation == IDLE) { return false; } final int animation = local.getAnimation(); if (animation == IDLE) { if (lastAnimating != null && Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0) { lastAnimation = IDLE; lastAnimating = null; lastInteract = null; lastInteracting = null; return true; } } else { lastAnimating = Instant.now(); } return false; }  @Subscribe void onAnimationChanged(AnimationChanged event); @Subscribe void onInteractingChanged(InteractingChanged event); @Subscribe void onGameStateChanged(GameStateChanged gameStateChanged); @Subscribe void onHitsplatApplied(HitsplatApplied event); @Subscribe void onGraphicChanged(GraphicChanged event); @Subscribe void onGameTick(GameTick event);  }
@Test public void checkAnimationIdle() { when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE); AnimationChanged animationChanged = new AnimationChanged(); animationChanged.setActor(player); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(new GameTick()); when(player.getAnimation()).thenReturn(AnimationID.IDLE); plugin.onAnimationChanged(animationChanged); plugin.onGameTick(new GameTick()); verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!"); }