Class Time

java.lang.Object
net.storm.sdk.commons.Time

public class Time extends Object
A utility class for all Time related things such as sleeping.
  • Constructor Details

    • Time

      public Time()
  • Method Details

    • sleep

      public static boolean sleep(long ms)
      Sleep will not execute on the client thread, as this may hang the client.
      Parameters:
      ms - The amount of milliseconds to sleep.
      Returns:
      Whether the sleep call was successful.
    • sleep

      public static boolean sleep(int min, int max)
      Sleeps for a random amount of time between a given range. Sleep will not execute on the client thread, as this may hang the client.
      Parameters:
      min - The minimum amount of milliseconds to sleep.
      max - The maximum amount of milliseconds to sleep.
      Returns:
      Whether the sleep call was successful.
    • sleepUntil

      public static boolean sleepUntil(BooleanSupplier supplier, BooleanSupplier resetSupplier, int pollingRate, int timeOut)
      Sleeps until the given condition is true. Sleep will not execute on the client thread, as this may hang the client.
      Parameters:
      supplier - The completion condition.
      resetSupplier - The condition to reset the sleep timer.
      pollingRate - The amount of time to check whether the given conditions are true.
      timeOut - The amount of time until a timeout.
      Returns:
      Whether the sleep call was successful.
    • sleepUntil

      public static boolean sleepUntil(BooleanSupplier supplier, BooleanSupplier resetSupplier, int timeOut)
      Sleeps until the given condition is true. Sleep will not execute on the client thread, as this may hang the client.
      Parameters:
      supplier - The completion condition.
      resetSupplier - The condition to reset the sleep timer.
      timeOut - The amount of time until a timeout.
      Returns:
      Whether the sleep call was successful.
    • sleepUntil

      public static boolean sleepUntil(BooleanSupplier supplier, int pollingRate, int timeOut)
      Sleeps until the given condition is true. Sleep will not execute on the client thread, as this may hang the client.
      Parameters:
      supplier - The completion condition.
      pollingRate - The amount of time to check whether the given conditions are true.
      timeOut - The amount of time until a timeout.
      Returns:
      Whether the sleep call was successful.
    • sleepUntil

      public static boolean sleepUntil(BooleanSupplier supplier, int timeOut)
      Sleeps until the given condition is true. Sleep will not execute on the client thread, as this may hang the client.
      Parameters:
      supplier - The completion condition.
      timeOut - The amount of time until a timeout.
      Returns:
      Whether the sleep call was successful.
    • sleepTicks

      public static boolean sleepTicks(int ticks)
      Sleeps for given amount of ticks. Sleep will not execute on the client thread, as this may hang the client.
      Parameters:
      ticks - Amount of time to sleep in ticks.
      Returns:
      Whether the sleep call was successful.
    • sleepTick

      public static boolean sleepTick()
      Sleeps for one game tick. Sleep will not execute on the client thread, as this may hang the client.
      Returns:
      Whether the sleep call was successful.
    • sleepTicksUntil

      public static boolean sleepTicksUntil(BooleanSupplier supplier, int ticks)
      Sleeps for given amount of ticks, or until given condition is true.
      Parameters:
      supplier - The break condition.
      ticks - Max. amount of ticks to sleep.
      Returns:
      Whether the sleep call was successful.
    • format

      public static String format(Duration duration)
      Parameters:
      duration - The duration value to format.
      Returns:
      A HH:MM:SS formatted string.