Return boolean for sleep methods instead of elapsed time
This commit is contained in:
parent
d094033e6c
commit
a7a172525c
@ -21,69 +21,55 @@ public class Util {
|
||||
return !player.isMoving() && !player.isAnimating();
|
||||
}
|
||||
|
||||
public static int sleepUntilMoving() {
|
||||
public static boolean sleepUntilMoving() {
|
||||
return sleepUntilMoving(Calculations.random(3000, 3500));
|
||||
}
|
||||
|
||||
public static int sleepUntilMoving(long timeout) {
|
||||
public static boolean sleepUntilMoving(long timeout) {
|
||||
long start = System.currentTimeMillis();
|
||||
Player player = Players.localPlayer();
|
||||
|
||||
MethodContext.sleepUntil(() -> player.isMoving(), timeout);
|
||||
|
||||
return (int) (System.currentTimeMillis() - start);
|
||||
return MethodContext.sleepUntil(player::isMoving, timeout);
|
||||
}
|
||||
|
||||
public static int sleepUntilAnimating() {
|
||||
public static boolean sleepUntilAnimating() {
|
||||
return sleepUntilAnimating(Calculations.random(3000, 3500));
|
||||
}
|
||||
|
||||
public static int sleepUntilAnimating(long timeout) {
|
||||
public static boolean sleepUntilAnimating(long timeout) {
|
||||
long start = System.currentTimeMillis();
|
||||
Player player = Players.localPlayer();
|
||||
|
||||
MethodContext.sleepUntil(() -> player.isAnimating(), timeout);
|
||||
|
||||
return (int) (System.currentTimeMillis() - start);
|
||||
return MethodContext.sleepUntil(player::isAnimating, timeout);
|
||||
}
|
||||
|
||||
public static int sleepUntilMovingOrAnimating() {
|
||||
public static boolean sleepUntilMovingOrAnimating() {
|
||||
return sleepUntilMovingOrAnimating(Calculations.random(3000, 3500));
|
||||
}
|
||||
|
||||
public static int sleepUntilMovingOrAnimating(long timeout) {
|
||||
public static boolean sleepUntilMovingOrAnimating(long timeout) {
|
||||
long start = System.currentTimeMillis();
|
||||
Player player = Players.localPlayer();
|
||||
|
||||
MethodContext.sleepUntil(() -> player.isMoving() || player.isAnimating(), timeout);
|
||||
|
||||
return (int) (System.currentTimeMillis() - start);
|
||||
return MethodContext.sleepUntil(() -> player.isMoving() || player.isAnimating(), timeout);
|
||||
}
|
||||
|
||||
public static int sleepUntilMovingAndAnimating() {
|
||||
public static boolean sleepUntilMovingAndAnimating() {
|
||||
return sleepUntilMovingAndAnimating(Calculations.random(5000, 5500));
|
||||
}
|
||||
|
||||
public static int sleepUntilMovingAndAnimating(long timeout) {
|
||||
int elapsed = sleepUntilMovingOrAnimating(timeout);
|
||||
|
||||
public static boolean sleepUntilMovingAndAnimating(long timeout) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
if (timeout - elapsed < 0) {
|
||||
return elapsed;
|
||||
if (!sleepUntilMoving(timeout)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MethodContext.sleepWhile(() -> Players.localPlayer().isMoving(), timeout - elapsed);
|
||||
|
||||
elapsed += (System.currentTimeMillis() - start);
|
||||
|
||||
if (timeout - elapsed < 0) {
|
||||
return elapsed;
|
||||
if (!MethodContext.sleepWhile(() -> Players.localPlayer().isMoving(), timeout - (System.currentTimeMillis() - start))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
elapsed += sleepUntilAnimating(timeout - elapsed);
|
||||
|
||||
return elapsed;
|
||||
return sleepUntilAnimating(timeout - (System.currentTimeMillis() - start));
|
||||
}
|
||||
|
||||
public static int getCurrentHP() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user