Class Delay


  • public class Delay
    extends java.lang.Object
    The Delay class provides methods for introducing delays and waiting for specific conditions during script execution.
    • Constructor Summary

      Constructors 
      Constructor Description
      Delay()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void ticks​(int amount)
      Waits for the provided amount of Game ticks to occur.
      static boolean until​(java.util.function.BooleanSupplier condition, int minTimeout, int maxTimeout)
      Waits until a specified condition is met or a timeout occurs, using default interval values.
      static boolean until​(java.util.function.BooleanSupplier condition, int minInterval, int maxInterval, long timeout)
      Waits until a specified condition is met or a timeout occurs.
      static boolean untilAnimating​(int minTimeout, int maxTimeout)
      Waits until the local Player is animating, where "animating" is defined by the RSActor.getAnimation() != -1, or a timeout occurs.
      static boolean untilAnimating​(RSActor rsa, int minTimeout, int maxTimeout)
      Waits until the specified actor is animating, where "animating" is defined by the RSActor.getAnimation() != -1, or a timeout occurs.
      static boolean untilBankIsOpen​(int minTimeout, int maxTimeout)
      Waits until Bank.isOpen() or a timeout occurs.
      static boolean untilIdle​(int idleLimit, int minTimeout, int maxTimeout)
      Waits until the local player becomes idle, where "idle" is defined by the RSActor.getAnimation() == -1, until a specified number of idle checks are met or a timeout occurs.
      static boolean untilIdle​(RSActor rsa, int idleLimit, int minTimeout, int maxTimeout)
      Waits until the specified actor becomes idle, where "idle" is defined by the RSActor.getAnimation() == -1, until a specified number of idle checks are met or a timeout occurs.
      static boolean untilInteracting​(int minTimeout, int maxTimeout)
      Waits until the local Player RSActor.isInteracting() or a timeout occurs.
      static boolean untilInteracting​(RSActor rsa, int minTimeout, int maxTimeout)
      Waits until the specified Actor RSActor.isInteracting() or a timeout occurs.
      static boolean untilMoving​(int minTimeout, int maxTimeout)
      Waits until the local Player RSActor.isMoving() or a timeout occurs.
      static boolean untilMoving​(RSActor rsa, int minTimeout, int maxTimeout)
      Waits until the specified Actor RSActor.isMoving() or a timeout occurs.
      static boolean untilShopIsOpen​(int minTimeout, int maxTimeout)
      Waits until Shop.isOpen() or a timeout occurs.
      static void wait​(int timeout)
      Pauses the script execution for the specified timeout.
      static void wait​(int minTimeout, int maxTimeout)
      Pauses the script execution for a random timeout within the specified range.
      static boolean whileAnimating​(int minTimeout, int maxTimeout)
      Waits while the local Player is animating, where "animating" is defined by the RSActor.getAnimation() != -1, or a timeout occurs.
      static boolean whileAnimating​(RSActor rsa, int minTimeout, int maxTimeout)
      Waits while the specified actor is animating, where "animating" is defined by the RSActor.getAnimation() != -1, or a timeout occurs.
      static boolean whileBankIsOpen​(int minTimeout, int maxTimeout)
      Waits while Bank.isOpen() or a timeout occurs.
      static boolean whileInteracting​(int minTimeout, int maxTimeout)
      Waits while the local Player RSActor.isInteracting() or a timeout occurs.
      static boolean whileInteracting​(RSActor rsa, int minTimeout, int maxTimeout)
      Waits while the specified Actor RSActor.isInteracting() or a timeout occurs.
      static boolean whileMoving​(int minTimeout, int maxTimeout)
      Waits while the local Player RSActor.isMoving() or a timeout occurs.
      static boolean whileMoving​(RSActor rsa, int minTimeout, int maxTimeout)
      Waits while the specified Actor RSActor.isMoving() or a timeout occurs.
      static boolean whileShopIsOpen​(int minTimeout, int maxTimeout)
      Waits while Shop.isOpen() or a timeout occurs.
      • Methods inherited from class java.lang.Object

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

      • Delay

        public Delay()
    • Method Detail

      • wait

        public static void wait​(int timeout)
        Pauses the script execution for the specified timeout.
        Parameters:
        timeout - The time to wait in milliseconds.
      • wait

        public static void wait​(int minTimeout,
                                int maxTimeout)
        Pauses the script execution for a random timeout within the specified range.
        Parameters:
        minTimeout - The minimum time to wait in milliseconds.
        maxTimeout - The maximum time to wait in milliseconds.
      • until

        public static boolean until​(java.util.function.BooleanSupplier condition,
                                    int minInterval,
                                    int maxInterval,
                                    long timeout)
        Waits until a specified condition is met or a timeout occurs.
        Parameters:
        condition - The condition to check.
        minInterval - The minimum interval between checks.
        maxInterval - The maximum interval between checks.
        timeout - The timeout duration.
        Returns:
        true if the condition is met before the timeout, false otherwise.
      • until

        public static boolean until​(java.util.function.BooleanSupplier condition,
                                    int minTimeout,
                                    int maxTimeout)
        Waits until a specified condition is met or a timeout occurs, using default interval values.
        Parameters:
        condition - The condition to check.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the condition is met before the timeout, false otherwise.
      • untilMoving

        public static boolean untilMoving​(int minTimeout,
                                          int maxTimeout)
        Waits until the local Player RSActor.isMoving() or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player or NPC is moving before the timeout, false otherwise.
      • untilMoving

        public static boolean untilMoving​(RSActor rsa,
                                          int minTimeout,
                                          int maxTimeout)
        Waits until the specified Actor RSActor.isMoving() or a timeout occurs.
        Parameters:
        rsa - The actor to reference.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player or NPC isMoving() before the timeout, false otherwise.
      • whileMoving

        public static boolean whileMoving​(int minTimeout,
                                          int maxTimeout)
        Waits while the local Player RSActor.isMoving() or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player or NPC is moving before the timeout, false otherwise.
      • whileMoving

        public static boolean whileMoving​(RSActor rsa,
                                          int minTimeout,
                                          int maxTimeout)
        Waits while the specified Actor RSActor.isMoving() or a timeout occurs.
        Parameters:
        rsa - The actor to reference.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player or NPC is moving before the timeout, false otherwise.
      • untilInteracting

        public static boolean untilInteracting​(int minTimeout,
                                               int maxTimeout)
        Waits until the local Player RSActor.isInteracting() or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player or NPC is moving before the timeout, false otherwise.
      • untilInteracting

        public static boolean untilInteracting​(RSActor rsa,
                                               int minTimeout,
                                               int maxTimeout)
        Waits until the specified Actor RSActor.isInteracting() or a timeout occurs.
        Parameters:
        rsa - The actor to reference.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player or NPC is moving before the timeout, false otherwise.
      • whileInteracting

        public static boolean whileInteracting​(int minTimeout,
                                               int maxTimeout)
        Waits while the local Player RSActor.isInteracting() or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player or NPC is moving before the timeout, false otherwise.
      • whileInteracting

        public static boolean whileInteracting​(RSActor rsa,
                                               int minTimeout,
                                               int maxTimeout)
        Waits while the specified Actor RSActor.isInteracting() or a timeout occurs.
        Parameters:
        rsa - The actor to reference.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player or NPC is moving before the timeout, false otherwise.
      • untilAnimating

        public static boolean untilAnimating​(int minTimeout,
                                             int maxTimeout)
        Waits until the local Player is animating, where "animating" is defined by the RSActor.getAnimation() != -1, or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the actor starts playing an animation before the timeout, false otherwise.
      • untilAnimating

        public static boolean untilAnimating​(RSActor rsa,
                                             int minTimeout,
                                             int maxTimeout)
        Waits until the specified actor is animating, where "animating" is defined by the RSActor.getAnimation() != -1, or a timeout occurs.
        Parameters:
        rsa - The actor to reference.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the actor starts playing an animation before the timeout, false otherwise.
      • whileAnimating

        public static boolean whileAnimating​(int minTimeout,
                                             int maxTimeout)
        Waits while the local Player is animating, where "animating" is defined by the RSActor.getAnimation() != -1, or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the player is not playing an animation before the timeout, false otherwise.
      • whileAnimating

        public static boolean whileAnimating​(RSActor rsa,
                                             int minTimeout,
                                             int maxTimeout)
        Waits while the specified actor is animating, where "animating" is defined by the RSActor.getAnimation() != -1, or a timeout occurs.
        Parameters:
        rsa - The actor to reference.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the actor is not playing an animation before the timeout, false otherwise.
      • untilIdle

        public static boolean untilIdle​(int idleLimit,
                                        int minTimeout,
                                        int maxTimeout)
        Waits until the local player becomes idle, where "idle" is defined by the RSActor.getAnimation() == -1, until a specified number of idle checks are met or a timeout occurs.
        Parameters:
        idleLimit - The number of idle checks required.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the actor becomes idle before the timeout, false otherwise.
      • untilIdle

        public static boolean untilIdle​(RSActor rsa,
                                        int idleLimit,
                                        int minTimeout,
                                        int maxTimeout)
        Waits until the specified actor becomes idle, where "idle" is defined by the RSActor.getAnimation() == -1, until a specified number of idle checks are met or a timeout occurs.
        Parameters:
        rsa - The actor to reference.
        idleLimit - The number of idle checks required.
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the actor becomes idle before the timeout, false otherwise.
      • untilBankIsOpen

        public static boolean untilBankIsOpen​(int minTimeout,
                                              int maxTimeout)
        Waits until Bank.isOpen() or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the bank interface is open before the timeout, false otherwise.
      • whileBankIsOpen

        public static boolean whileBankIsOpen​(int minTimeout,
                                              int maxTimeout)
        Waits while Bank.isOpen() or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the bank interface is open before the timeout, false otherwise.
      • untilShopIsOpen

        public static boolean untilShopIsOpen​(int minTimeout,
                                              int maxTimeout)
        Waits until Shop.isOpen() or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the shop interface is open before the timeout, false otherwise.
      • whileShopIsOpen

        public static boolean whileShopIsOpen​(int minTimeout,
                                              int maxTimeout)
        Waits while Shop.isOpen() or a timeout occurs.
        Parameters:
        minTimeout - The minimum timeout duration.
        maxTimeout - The maximum timeout duration.
        Returns:
        true if the shop interface is open before the timeout, false otherwise.
      • ticks

        public static void ticks​(int amount)
        Waits for the provided amount of Game ticks to occur.