tbh i didnt like any of those answers. Maybe except for the condition sleep. Personally i would just use a timer. And a simple boolean check to weather it should interaction or keep waiting.
private long waitTimer = System.currentTimeMillis();
if (player animtaing) {
restart timer
}
else if (System.currentTimeMillis() - this.waitTimer > 3000){
start interaction
}
edit: if you dont understand how to make the timer concept. Here a simple timer class. Its been passed around for ages
public class Timer {
private long period;
private long start;
public Timer(long period) {
this.period = period;
this.start = System.currentTimeMillis();
}
public long getElapsed() {
return System.currentTimeMillis() - this.start;
}
public long getRemaining() {
return this.period - this.getElapsed();
}
public boolean isRunning() {
return this.getElapsed() <= this.period;
}
public void setPeriod(long period) {
this.period = period;
}
public void reset() {
this.start = System.currentTimeMillis();
}
public static String format(long milliSeconds) {
long secs = milliSeconds / 1000L;
return String.format("%02d:%02d:%02d", new Object[] {
Long.valueOf(secs / 3600L), Long.valueOf(secs % 3600L/ 60L), Long.valueOf(secs % 60L)
});
}
}