Class SimpleScheduler
java.lang.Object
ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Direct Known Subclasses:
SourceSecondsTimer,SourceSimpleTimer
Karma simple scheduler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanGet if the timer auto restartsabstract voidcancel()Cancel the schedulerabstract SimpleSchedulercancelAction(Consumer<Long> paramConsumer)Set the action to perform when the timer is cancelledstatic voidcancelFor(KarmaSource owner)Cancel the schedulerabstract SimpleSchedulerconditionalAction(TimeCondition paramTimeCondition, int paramInt, Consumer<Integer> paramConsumer)Add a conditional actionabstract SimpleSchedulerconditionalPeriodAction(TimeCondition paramTimeCondition, long paramLong, Consumer<Long> paramConsumer)Add a conditional actionabstract SimpleSchedulerSet the action to perform when the timer is completely endedabstract SimpleSchedulerexactPeriodAction(long paramLong, Runnable paramRunnable)Add an action to perform when the timer reaches the specified millisecondabstract SimpleSchedulerexactSecondPeriodAction(int paramInt, Runnable paramRunnable)Add an action to perform when the timer reaches the specified secondFormat the current timer timeintgetId()Get the scheduler IDabstract longGet the timer millisecondsabstract longGet the timer start timeabstract longGet the timer configured periodGet the scheduler sourcelongGet the timer time under the specified time unitabstract booleanGet if the timer is cancelledabstract booleanGet if the timer has multi-threading enabledabstract booleanisPaused()Get if the timer is pausedabstract booleanGet if the timer is runningabstract SimpleSchedulermultiThreading(boolean paramBoolean)Set if the timer runs on another threadabstract voidpause()Pause the schedulerabstract SimpleSchedulerpauseAction(Consumer<Long> paramConsumer)Set the action to perform when the timer is pausedabstract SimpleSchedulerperiodChangeAction(Consumer<Long> paramConsumer)Add an action when the timer passes a millisecondvoidrequestAsync(Runnable action)Deprecated.voidrequestSync(Runnable action)Deprecated.abstract voidrestart()Restart the schedulerabstract SimpleSchedulerrestartAction(Runnable paramRunnable)Set the action to perform when the timer is restartedabstract SimpleSchedulersecondChangeAction(Consumer<Integer> paramConsumer)Add an action when the timer passes a secondabstract voidstart()Start the schedulerabstract SimpleSchedulerstartAction(Runnable paramRunnable)Set the action to perform when the timer is startedtimeLeft(boolean millis)Get the timer time left to be finishedabstract SimpleSchedulerupdateAutoRestart(boolean paramBoolean)Set if the timer should auto restart when it endsabstract SimpleSchedulerwithPeriod(Number paramNumber)Set the timer update period
-
Constructor Details
-
SimpleScheduler
Initialize the scheduler- Parameters:
owner- the scheduler source
-
-
Method Details
-
cancelFor
Cancel the scheduler- Parameters:
owner- the scheduler source
-
cancel
public abstract void cancel()Cancel the scheduler -
pause
public abstract void pause()Pause the scheduler -
start
Start the scheduler- Throws:
TimerAlreadyStarted- if the scheduler is already started
-
restart
public abstract void restart()Restart the scheduler -
updateAutoRestart
Set if the timer should auto restart when it ends- Parameters:
paramBoolean- if the timer should auto restart- Returns:
- this instance
-
withPeriod
Set the timer update period- Parameters:
paramNumber- the period- Returns:
- this instance
-
multiThreading
Set if the timer runs on another thread- Parameters:
paramBoolean- if the timer has multi-threading- Returns:
- this instance
-
exactSecondPeriodAction
Add an action to perform when the timer reaches the specified second- Parameters:
paramInt- the secondparamRunnable- the action to perform- Returns:
- this instance
-
exactPeriodAction
Add an action to perform when the timer reaches the specified millisecond- Parameters:
paramLong- the millisecondparamRunnable- the action to perform- Returns:
- this instance
-
secondChangeAction
Add an action when the timer passes a second- Parameters:
paramConsumer- the action to perform- Returns:
- this instance
-
periodChangeAction
Add an action when the timer passes a millisecond- Parameters:
paramConsumer- the action to perform- Returns:
- this instance
-
cancelAction
Set the action to perform when the timer is cancelled- Parameters:
paramConsumer- the action to perform- Returns:
- this instance
-
pauseAction
Set the action to perform when the timer is paused- Parameters:
paramConsumer- the action to perform- Returns:
- this instance
-
startAction
Set the action to perform when the timer is started- Parameters:
paramRunnable- the action to perform- Returns:
- this instance
-
endAction
Set the action to perform when the timer is completely ended- Parameters:
paramRunnable- the action to perform- Returns:
- this instance
-
restartAction
Set the action to perform when the timer is restarted- Parameters:
paramRunnable- the action to perform- Returns:
- this instance
-
conditionalAction
public abstract SimpleScheduler conditionalAction(TimeCondition paramTimeCondition, int paramInt, Consumer<Integer> paramConsumer)Add a conditional action- Parameters:
paramTimeCondition- the condition that the timer must completeparamInt- the timer secondparamConsumer- the action to perform- Returns:
- this instance
-
conditionalPeriodAction
public abstract SimpleScheduler conditionalPeriodAction(TimeCondition paramTimeCondition, long paramLong, Consumer<Long> paramConsumer)Add a conditional action- Parameters:
paramTimeCondition- the condition that the timer must completeparamLong- the timer millisecondparamConsumer- the action to perform- Returns:
- this instance
-
isCancelled
public abstract boolean isCancelled()Get if the timer is cancelled- Returns:
- if the timer is cancelled
-
isRunning
public abstract boolean isRunning()Get if the timer is running- Returns:
- if the timer is running
-
isPaused
public abstract boolean isPaused()Get if the timer is paused- Returns:
- if the timer is paused
-
autoRestart
public abstract boolean autoRestart()Get if the timer auto restarts- Returns:
- if the timer starts the timer automatically when it ends
-
isMultiThreading
public abstract boolean isMultiThreading()Get if the timer has multi-threading enabled- Returns:
- if the timer runs on another thread
-
getOriginalTime
public abstract long getOriginalTime()Get the timer start time- Returns:
- the timer start time
-
getPeriod
public abstract long getPeriod()Get the timer configured period- Returns:
- the timer update period
-
getMillis
public abstract long getMillis()Get the timer milliseconds- Returns:
- the timer exact time
-
getTime
Get the timer time under the specified time unit- Parameters:
unit- the time unit- Returns:
- the timer time in the specified time unit if possible
-
format
Format the current timer time- Parameters:
unit- the time unitname- the unit name- Returns:
- the formatted timer time
-
timeLeft
Get the timer time left to be finished- Parameters:
millis- include the milliseconds on the format- Returns:
- the time left format
-
requestSync
Deprecated.Request a synchronous task- Parameters:
action- the action to perform
-
requestAsync
Deprecated.Request an asynchronous task- Parameters:
action- the action to perform
-
getSource
Get the scheduler source- Returns:
- the scheduler source
-
getId
public final int getId()Get the scheduler ID- Returns:
- the scheduler ID
-
KarmaSource.async()