Item food = getInventory().getItem("Example");
if (food != null) {
if(food.interact("Eat")){
new ConditionalSleep(random(2500, 5000)) {
@Override
public boolean condition() {
return !myPlayer().isAnimating();
}
}.sleep();
}
}
It'll sleep until the return condition is met or until its slept for 2500-5000 ms