public class AnimationCheck extends Script {
private final Timer animationTimer = new Timer(3_000);
@Override
public void onStart() {
}
@Override
public int onLoop() {
if(myPlayer().isAnimating()){
animationTimer.reset();
}
if(animationTimer.isRunning()){
log("Animating");
}else{
//Start doing whatever you wanted to do
}
return 50;
}
}
Basic Timer class
public class Timer {
private long period;
private long startTime;
public Timer(long period) {
this.period = period;
startTime = System.currentTimeMillis();
}
public boolean isRunning() {
return getElapsed() < period;
}
public long getElapsed() {
return System.currentTimeMillis() - startTime;
}
public long getRemaining() {
return period - getElapsed();
}
public void reset() {
startTime = System.currentTimeMillis();
}
public void stop() {
period = 0;
}
public static String formatTime(long ms) {
long sec = ms / 1000L;
return String.format("%02d:%02d:%02d", Long.valueOf(sec / 3600L), Long.valueOf((sec % 3600L) / 60L), Long.valueOf(sec % 60L));
}
}