import org.osbot.rs07.utility.ConditionalSleep;
import java.util.function.BooleanSupplier;
public class Sleep extends ConditionalSleep {
private final BooleanSupplier condition;
public Sleep(final BooleanSupplier condition, final int timeout) {
super(timeout);
this.condition = condition;
}
public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) {
return new Sleep(condition, timeout).sleep();
}
@Override
public final boolean condition() {
return condition.getAsBoolean();
}
}
Usage
Sleep.sleepUntil(() -> !Sleep.sleepUntil(api.myPlayer()::isAnimating, random(4000, 8000)), random(20000, 40000))
Sleep until haven't animated for 4-8 seconds, returns boolean whether condition was met or timed out