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();
|
return !player.isMoving() && !player.isAnimating();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMoving() {
|
public static boolean sleepUntilMoving() {
|
||||||
return sleepUntilMoving(Calculations.random(3000, 3500));
|
return sleepUntilMoving(Calculations.random(3000, 3500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMoving(long timeout) {
|
public static boolean sleepUntilMoving(long timeout) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Player player = Players.localPlayer();
|
Player player = Players.localPlayer();
|
||||||
|
|
||||||
MethodContext.sleepUntil(() -> player.isMoving(), timeout);
|
return MethodContext.sleepUntil(player::isMoving, timeout);
|
||||||
|
|
||||||
return (int) (System.currentTimeMillis() - start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilAnimating() {
|
public static boolean sleepUntilAnimating() {
|
||||||
return sleepUntilAnimating(Calculations.random(3000, 3500));
|
return sleepUntilAnimating(Calculations.random(3000, 3500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilAnimating(long timeout) {
|
public static boolean sleepUntilAnimating(long timeout) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Player player = Players.localPlayer();
|
Player player = Players.localPlayer();
|
||||||
|
|
||||||
MethodContext.sleepUntil(() -> player.isAnimating(), timeout);
|
return MethodContext.sleepUntil(player::isAnimating, timeout);
|
||||||
|
|
||||||
return (int) (System.currentTimeMillis() - start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMovingOrAnimating() {
|
public static boolean sleepUntilMovingOrAnimating() {
|
||||||
return sleepUntilMovingOrAnimating(Calculations.random(3000, 3500));
|
return sleepUntilMovingOrAnimating(Calculations.random(3000, 3500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMovingOrAnimating(long timeout) {
|
public static boolean sleepUntilMovingOrAnimating(long timeout) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Player player = Players.localPlayer();
|
Player player = Players.localPlayer();
|
||||||
|
|
||||||
MethodContext.sleepUntil(() -> player.isMoving() || player.isAnimating(), timeout);
|
return MethodContext.sleepUntil(() -> player.isMoving() || player.isAnimating(), timeout);
|
||||||
|
|
||||||
return (int) (System.currentTimeMillis() - start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMovingAndAnimating() {
|
public static boolean sleepUntilMovingAndAnimating() {
|
||||||
return sleepUntilMovingAndAnimating(Calculations.random(5000, 5500));
|
return sleepUntilMovingAndAnimating(Calculations.random(5000, 5500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMovingAndAnimating(long timeout) {
|
public static boolean sleepUntilMovingAndAnimating(long timeout) {
|
||||||
int elapsed = sleepUntilMovingOrAnimating(timeout);
|
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
if (timeout - elapsed < 0) {
|
if (!sleepUntilMoving(timeout)) {
|
||||||
return elapsed;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodContext.sleepWhile(() -> Players.localPlayer().isMoving(), timeout - elapsed);
|
if (!MethodContext.sleepWhile(() -> Players.localPlayer().isMoving(), timeout - (System.currentTimeMillis() - start))) {
|
||||||
|
return false;
|
||||||
elapsed += (System.currentTimeMillis() - start);
|
|
||||||
|
|
||||||
if (timeout - elapsed < 0) {
|
|
||||||
return elapsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsed += sleepUntilAnimating(timeout - elapsed);
|
return sleepUntilAnimating(timeout - (System.currentTimeMillis() - start));
|
||||||
|
|
||||||
return elapsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCurrentHP() {
|
public static int getCurrentHP() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user