Timer
Small elapsed-time timer utility for script flow checks.
ClassRLPlugins API
public class TimerThese helpers wait. Call them only from VitaPlugin.loop(); on the game thread, for example in a @Subscribe method, they freeze the game.
Members
Constructors
- newTimer()
Creates and starts an elapsed-time timer with no fixed duration.
- newTimer(long)
Creates and starts a timer.
Methods
- longelapsed()
Gets elapsed time since the last reset.
- booleanfinished()
Checks whether the timer duration has elapsed.
- longgetElapsed()
Gets elapsed time since the last reset.
- longgetRemaining()
Gets remaining time.
- booleanisPaused()
Checks whether elapsed time is currently paused.
- voidpause()
Pauses elapsed-time advancement until resumed.
- longremaining()
Gets remaining time.
- voidreset()
Restarts the timer from now.
- voidresume()
Resumes elapsed-time advancement without counting paused time.
- booleanrunning()
Checks whether the timer is still running.
- voidsetRunTime(long)
Sets the timer duration without changing its start time.
- voidstart()
Starts the timer from now.
Timer()
public Timer()Creates and starts an elapsed-time timer with no fixed duration.
Timer(long)
public Timer(long durationMs)Creates and starts a timer.
Parameters
durationMs- Timer duration in milliseconds.
elapsed()
public long elapsed()Gets elapsed time since the last reset.
Returns
Elapsed milliseconds.
finished()
public boolean finished()Checks whether the timer duration has elapsed.
Returns
True when finished.
getElapsed()
public long getElapsed()Gets elapsed time since the last reset.
Returns
Elapsed milliseconds.
getRemaining()
public long getRemaining()Gets remaining time.
Returns
Remaining milliseconds, clamped to zero.
isPaused()
public boolean isPaused()Checks whether elapsed time is currently paused.
Returns
True while paused.
pause()
public void pause()Pauses elapsed-time advancement until resumed.
remaining()
public long remaining()Gets remaining time.
Returns
Remaining milliseconds, clamped to zero.
reset()
public void reset()Restarts the timer from now.
resume()
public void resume()Resumes elapsed-time advancement without counting paused time.
running()
public boolean running()Checks whether the timer is still running.
Returns
True while time remains.
setRunTime(long)
public void setRunTime(long durationMs)Sets the timer duration without changing its start time.
Parameters
durationMs- Timer duration in milliseconds.
start()
public void start()Starts the timer from now.
Also allowed
Every class has these, as in plain Java.
equals, toString