Class Sleep


  • public class Sleep
    extends java.lang.Object
    Contains static methods for sleeping
    • Constructor Summary

      Constructors 
      Constructor Description
      Sleep()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void sleep​(long ms)
      Sleeps for specified milliseconds Do NOT use this in custom mouse algorithms, as it will cause blocking forever during random events, use Thread#sleep instead
      static void sleep​(long min, long max)
      Sleeps for a random number of milliseconds between min (inclusive) and max (exclusive)
      static void sleepTick()
      Sleeps until the start of the next game tick
      static void sleepTicks​(int ticks)
      Sleeps through the specified number of game ticks
      static boolean sleepUntil​(Condition predicate, long timeout)
      Sleeps until the passed predicate returns true or sleeping for longer than the timeout.
      static boolean sleepUntil​(Condition predicate, long timeout, long polling)
      Sleep until the given timeout value or condition is met; polling at a rate defined by used.
      static boolean sleepUntil​(Condition predicate, Condition resetCondition, long timeout, long polling)
      Sleep until the given timeout value after a false reset condition or the condition is met.
      static boolean sleepWhile​(Condition predicate, long timeout)
      Sleeps until the passed predicate returns false.
      static boolean sleepWhile​(Condition predicate, long timeout, long polling)
      Sleep while the given timeout value or condition is met; polling at a rate defined by used.
      static boolean sleepWhile​(Condition predicate, Condition resetCondition, long timeout, long polling)
      Sleeps while the given timeout value after a false reset condition or the condition is met.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Sleep

        public Sleep()
    • Method Detail

      • sleep

        public static void sleep​(long ms)
        Sleeps for specified milliseconds Do NOT use this in custom mouse algorithms, as it will cause blocking forever during random events, use Thread#sleep instead
        Parameters:
        ms - milliseconds to sleep for
      • sleep

        public static void sleep​(long min,
                                 long max)
        Sleeps for a random number of milliseconds between min (inclusive) and max (exclusive)
        Parameters:
        min - minimum number of milliseconds
        max - maximum number of milliseconds
      • sleepUntil

        public static boolean sleepUntil​(Condition predicate,
                                         long timeout)
        Sleeps until the passed predicate returns true or sleeping for longer than the timeout. Polls every 50ms by default.
        Parameters:
        predicate - predicate
        timeout - millis time out
        Returns:
        True if condition succeeds, false if timeout is reached
      • sleepUntil

        public static boolean sleepUntil​(Condition predicate,
                                         long timeout,
                                         long polling)
        Sleep until the given timeout value or condition is met; polling at a rate defined by used.
        Parameters:
        predicate - the condition to check at the given polling rate
        timeout - the timeout is the max amount of time allowed to sleep before continuing
        polling - the polling is rate at which to check the given condition
      • sleepUntil

        public static boolean sleepUntil​(Condition predicate,
                                         Condition resetCondition,
                                         long timeout,
                                         long polling)
        Sleep until the given timeout value after a false reset condition or the condition is met. Polls at the rate set. Please be careful with the reset condition as something that is always true will keep sleeping until the script is stopped.
        Parameters:
        predicate - the condition to check for completion at the given polling rate
        resetCondition - the condition that will reset the timeout as long as it's true
        timeout - the timeout is the max amount of time allowed to sleep before continuing
        polling - the polling is rate at which to check the given condition
      • sleepWhile

        public static boolean sleepWhile​(Condition predicate,
                                         long timeout)
        Sleeps until the passed predicate returns false. Polls every 50ms by default.
        Parameters:
        predicate - predicate
        timeout - millis time out
      • sleepWhile

        public static boolean sleepWhile​(Condition predicate,
                                         long timeout,
                                         long polling)
        Sleep while the given timeout value or condition is met; polling at a rate defined by used.
        Parameters:
        predicate - the predicate to check at the given polling rate
        timeout - the timeout is the max amount of time allowed to sleep before continuing
        polling - the polling is rate at which to check the given condition
      • sleepWhile

        public static boolean sleepWhile​(Condition predicate,
                                         Condition resetCondition,
                                         long timeout,
                                         long polling)
        Sleeps while the given timeout value after a false reset condition or the condition is met. Polls at the rate set. Please be careful with the reset condition as something that is always true will keep sleeping until the script is stopped.
        Parameters:
        predicate - the condition to check for completion at the given polling rate
        resetCondition - the condition that will reset the timeout as long as it's true
        timeout - the timeout is the max amount of time allowed to sleep before continuing
        polling - the polling is rate at which to check the given condition
      • sleepTick

        public static void sleepTick()
        Sleeps until the start of the next game tick
      • sleepTicks

        public static void sleepTicks​(int ticks)
        Sleeps through the specified number of game ticks
        Parameters:
        ticks - the number of ticks to sleep through which includes the tick you're currently in