Class Timer

java.lang.Object
ActiverseUtils.Timer

public class Timer extends Object
Advanced Timer class for game loop timing, delays, and repeated events. Part of the Activerse engine.
Version:
1.4.0
Author:
Knivier
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a Timer with no duration (manual control).
    Timer(long durationMillis, boolean repeat)
    Constructs a Timer with optional duration and repeat flag.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns how much time has elapsed in milliseconds.
    long
    Returns the remaining time in milliseconds, or 0 if expired.
    boolean
    Returns true if the timer has finished (only applies if duration > 0).
    boolean
    Returns true if the timer is paused.
    boolean
    Returns true if the timer is set to repeat.
    boolean
    Returns true if the timer is currently running (not paused or stopped).
    void
    Pauses the timer.
    void
    Resets the timer without stopping it.
    void
     
    void
    setDuration(long durationMillis)
    Set a new duration for the timer (in milliseconds).
    void
    setRepeat(boolean repeat)
    Set whether the timer should repeat.
    void
    Starts or restarts the timer.
    void
    Stops the timer completely.

    Methods inherited from class java.lang.Object

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

    • Timer

      public Timer(long durationMillis, boolean repeat)
      Constructs a Timer with optional duration and repeat flag.
      Parameters:
      durationMillis - Timer duration in milliseconds (0 for infinite)
      repeat - Whether the timer repeats after duration
    • Timer

      public Timer()
      Constructs a Timer with no duration (manual control).
  • Method Details

    • start

      public void start()
      Starts or restarts the timer.
    • stop

      public void stop()
      Stops the timer completely.
    • pause

      public void pause()
      Pauses the timer.
    • resume

      public void resume()
    • reset

      public void reset()
      Resets the timer without stopping it.
    • getElapsedTime

      public long getElapsedTime()
      Returns how much time has elapsed in milliseconds.
    • getRemainingTime

      public long getRemainingTime()
      Returns the remaining time in milliseconds, or 0 if expired.
    • isFinished

      public boolean isFinished()
      Returns true if the timer has finished (only applies if duration > 0). Automatically resets if repeating.
    • isRunning

      public boolean isRunning()
      Returns true if the timer is currently running (not paused or stopped).
    • isPaused

      public boolean isPaused()
      Returns true if the timer is paused.
    • isRepeating

      public boolean isRepeating()
      Returns true if the timer is set to repeat.
    • setDuration

      public void setDuration(long durationMillis)
      Set a new duration for the timer (in milliseconds).
    • setRepeat

      public void setRepeat(boolean repeat)
      Set whether the timer should repeat.