Very simple snippet of an animation timer I used in one of my scripts.
Useful for things such as fletching, crafting, etc. Things where the animation returns -1 even when it is still doing an action.
Define variable
long lastAnimation = 0;
Usage:
if (myPlayer().isAnimating()) {
lastAnimation = System.currentTimeMillis();
} else if (System.currentTimeMillis() > (lastAnimation + int)){
//do action
}
int is the amount of time to sleep before it needs to click again if you haven't animated.
For example, if you wanted it to click after 2 seconds of not animating, you would put 2000 there.