Class Time
- java.lang.Object
-
- org.rspeer.commons.Time
-
public class Time extends Object
-
-
Constructor Summary
Constructors Constructor Description Time()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String
format(Duration duration)
static long
getDefaultThreshold()
Deprecated.static void
setDefaultThreshold(long defaultThreshold)
Deprecated.static void
sleep(int millis)
Deprecated.static void
sleep(int min, int max)
Deprecated.static void
sleep(long millis)
Deprecated.static void
sleep(long min, long max)
Deprecated.static boolean
sleepUntil(BooleanSupplier condition, int threshold, long timeout)
Deprecated.static boolean
sleepUntil(BooleanSupplier condition, long timeout)
Deprecated.static boolean
sleepUntil(BooleanSupplier condition, long threshold, long timeout)
Deprecated.static boolean
sleepUntil(BooleanSupplier condition, BooleanSupplier reset, long timeout)
Deprecated.static boolean
sleepUntil(BooleanSupplier condition, BooleanSupplier reset, long threshold, long timeout)
Deprecated.static boolean
sleepUntilForDuration(BooleanSupplier condition, long duration, long timeout)
Deprecated.static boolean
sleepUntilForDuration(BooleanSupplier condition, long duration, long threshold, long timeout)
Deprecated.static boolean
sleepWhile(BooleanSupplier condition, int threshold, long timeout)
Deprecated.static boolean
sleepWhile(BooleanSupplier condition, long timeout)
Deprecated.static boolean
sleepWhile(BooleanSupplier condition, BooleanSupplier reset, long timeout)
Deprecated.static boolean
sleepWhile(BooleanSupplier condition, BooleanSupplier reset, long threshold, long timeout)
Deprecated.
-
-
-
Method Detail
-
sleep
@Deprecated public static void sleep(int millis)
Deprecated.Sleep for specified amount of milliseconds- Parameters:
millis
- the amount of milliseconds you would like to sleep for
-
sleep
@Deprecated public static void sleep(long millis)
Deprecated.Sleep for specified amount of milliseconds- Parameters:
millis
- the amount of milliseconds you would like to sleep for
-
sleepUntilForDuration
@Deprecated public static boolean sleepUntilForDuration(BooleanSupplier condition, long duration, long timeout)
Deprecated.This sleep will sleep until the passed condition is true for your amount of duration. Useful for scenarios where you want to make sure a condition holds for a specific amount of time before stopping sleeping.
Calls
sleepUntil(BooleanSupplier, BooleanSupplier, long, long)
with a threshold of 50- Parameters:
condition
- the condition which has to validate for this method to stop sleepingduration
- the duartion for which the condition has to validate for for this method to stop sleepingtimeout
- the timeout after which this method will stop sleeping definitely.- Returns:
- true if the condition was validated for timeout ms before the timeout was reached.
-
sleepUntilForDuration
@Deprecated public static boolean sleepUntilForDuration(BooleanSupplier condition, long duration, long threshold, long timeout)
Deprecated.This sleep will sleep until the passed condition is true for your amount of duration. Useful for scenarios where you want to make sure a condition holds for a specific amount of time before stopping sleeping.
- Parameters:
condition
- the condition which has to validate for this method to stop sleepingduration
- the duartion for which the condition has to validate for for this method to stop sleepingtimeout
- the timeout after which this method will stop sleeping definitely.threshold
- the amount of milliseconds you would like to sleep each check- Returns:
- true if the condition was validated for timeout ms before the timeout was reached.
-
sleep
@Deprecated public static void sleep(int min, int max)
Deprecated.Sleep for a random amount of milliseconds between min and max- Parameters:
min
- the min amount of milliseconds to sleep formax
- the max amount of milliseconds to sleep for
-
sleep
@Deprecated public static void sleep(long min, long max)
Deprecated.Sleep for a random amount of milliseconds between min and max- Parameters:
min
- the min amount of milliseconds to sleep formax
- the max amount of milliseconds to sleep for
-
sleepUntil
@Deprecated public static boolean sleepUntil(BooleanSupplier condition, int threshold, long timeout)
Deprecated.Sleep until a condition is true. This is preferred to be used over static sleeps as with the dynamic nature of the game, sometimes you need to sleep for longer and other times you will need to sleep for a shorter amount of time.
- Parameters:
condition
- the condition which is validated to check if the bot needs to stop sleeping.threshold
- the amount of milliseconds to sleep each iteration.timeout
- the amount of milliseconds after which the bot will stop sleeping regardless of the condition- Returns:
- true if the condition was validated before the timeout was reached.
-
sleepUntil
@Deprecated public static boolean sleepUntil(BooleanSupplier condition, long threshold, long timeout)
Deprecated.Sleep until a condition is true. This is preferred to be used over static sleeps as with the dynamic nature of the game, sometimes you need to sleep for longer and other times you will need to sleep for a shorter amount of time.
- Parameters:
condition
- the condition which is validated to check if the bot needs to stop sleeping.threshold
- the amount of milliseconds to sleep each iteration.timeout
- the amount of milliseconds after which the bot will stop sleeping regardless of the condition- Returns:
- true if the condition was validated before the timeout was reached.
-
sleepUntil
@Deprecated public static boolean sleepUntil(BooleanSupplier condition, long timeout)
Deprecated.Sleep until a condition is true. This is preferred to be used over static sleeps as with the dynamic nature of the game, sometimes you need to sleep for longer and other times you will need to sleep for a shorter amount of time.
Calls
sleepUntil(BooleanSupplier, long, long)
with a threshold of 50.- Parameters:
condition
- the condition which is validated to check if the bot needs to stop sleeping.timeout
- the amount of milliseconds after which the bot will stop sleeping regardless of the condition- Returns:
- true if the condition was validated before the timeout was reached.
-
sleepUntil
@Deprecated public static boolean sleepUntil(BooleanSupplier condition, BooleanSupplier reset, long threshold, long timeout)
Deprecated.Sleep until a condition is true. This is preferred to be used over static sleeps as with the dynamic nature of the game, sometimes you need to sleep for longer and other times you will need to sleep for a shorter amount of time. You can pass a reset condition to reset the timeout timer.- Parameters:
condition
- the condition which is validated to check if the bot needs to stop sleeping.reset
- the condition which, if validated, will reset the timeout timer.threshold
- the amount of milliseconds to sleep each iteration.timeout
- the amount of milliseconds after which the bot will stop sleeping regardless of the condition- Returns:
true
if the condition was validated before the timeout was reached, orfalse
if the timeout was reached or the caller thread was interrupted.
-
sleepUntil
@Deprecated public static boolean sleepUntil(BooleanSupplier condition, BooleanSupplier reset, long timeout)
Deprecated.Sleep until a condition is true. This is preferred to be used over static sleeps as with the dynamic nature of the game, sometimes you need to sleep for longer and other times you will need to sleep for a shorter amount of time. You can pass a reset condition to reset the timeout timer.
Calls
sleepUntil(BooleanSupplier, BooleanSupplier, long, long)
with a threshold of 50.- Parameters:
condition
- the condition which is validated to check if the bot needs to stop sleeping.reset
- the condition which, if validated, will reset the timeout timer.timeout
- the amount of milliseconds after which the bot will stop sleeping regardless of the condition- Returns:
- true if the condition was validated before the timeout was reached.
-
sleepWhile
@Deprecated public static boolean sleepWhile(BooleanSupplier condition, BooleanSupplier reset, long threshold, long timeout)
Deprecated.
-
sleepWhile
@Deprecated public static boolean sleepWhile(BooleanSupplier condition, BooleanSupplier reset, long timeout)
Deprecated.
-
sleepWhile
@Deprecated public static boolean sleepWhile(BooleanSupplier condition, int threshold, long timeout)
Deprecated.Sleep as long as a condition is true or until timeout is reached. This method basically calls
sleepUntil(BooleanSupplier, long, long)
with the negated condition.- Parameters:
condition
- the condition that needs to be true for the sleep to continuethreshold
- the amount of milliseconds to sleep each loop fortimeout
- The timeout after which sleeping is stopped- Returns:
- true if the condition was invalidated before the timeout was reached
-
sleepWhile
@Deprecated public static boolean sleepWhile(BooleanSupplier condition, long timeout)
Deprecated.Sleep as long as a condition is true or until timeout is reached. This method basically calls
sleepUntil(BooleanSupplier, long, long)
with the negated condition. Uses the default threshold value of 50 milliseconds.- Parameters:
condition
- the condition that needs to be true for the sleep to continuetimeout
- The timeout after which sleeping is stopped- Returns:
- true if the condition was invalidated before the timeout was reached
-
getDefaultThreshold
@Deprecated public static long getDefaultThreshold()
Deprecated.
-
setDefaultThreshold
@Deprecated public static void setDefaultThreshold(long defaultThreshold)
Deprecated.
-
-