Package ml.karmaconfigs.api.common.timer
Class SourceSecondsTimer
java.lang.Object
ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
ml.karmaconfigs.api.common.timer.SourceSecondsTimer
Karma seconds scheduler
-
Constructor Summary
ConstructorsConstructorDescriptionSourceSecondsTimer(KarmaSource owner, int builtId)Initialize the schedulerSourceSecondsTimer(KarmaSource owner, Number time, boolean autoRestart)Initialize the scheduler -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet if the timer auto restartsvoidcancel()Cancel the schedulercancelAction(Consumer<Long> action)Set the action to perform when the timer is cancelledcancelUnloaded(boolean status)Notice when the timer has been stopped because its source has been also unloadedconditionalAction(TimeCondition condition, int condition_value, Consumer<Integer> action)Add a conditional actionconditionalPeriodAction(TimeCondition condition, long condition_value, Consumer<Long> action)Add a conditional actionSet the action to perform when the timer is completely endedexactPeriodAction(long time, Runnable task)Add an action to perform when the timer reaches the specified millisecondexactSecondPeriodAction(int time, Runnable task)Add an action to perform when the timer reaches the specified secondlongGet the timer millisecondslongGet the timer start timelongGet the timer configured periodbooleanGet if the timer is cancelledbooleanGet if the timer has multi-threading enabledbooleanisPaused()Get if the timer is pausedbooleanGet if the timer is runningmultiThreading(boolean status)Set if the timer runs on another threadvoidpause()Pause the schedulerpauseAction(Consumer<Long> action)Set the action to perform when the timer is pausedperiodChangeAction(Consumer<Long> action)Add an action when the timer passes a millisecondvoidrestart()Restart the schedulerrestartAction(Runnable task)Set the action to perform when the timer is restartedsecondChangeAction(Consumer<Integer> action)Add an action when the timer passes a secondvoidstart()Start the schedulerstartAction(Runnable task)Set the action to perform when the timer is startedupdateAutoRestart(boolean status)Set if the timer should auto restart when it endswithPeriod(Number time)Set the timer update periodMethods inherited from class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
cancelFor, format, getId, getSource, getTime, requestAsync, requestSync, timeLeft
-
Constructor Details
-
SourceSecondsTimer
Initialize the scheduler- Parameters:
owner- the scheduler ownertime- the scheduler start timeautoRestart- if the scheduler should auto-restart when it ends
-
SourceSecondsTimer
Initialize the scheduler- Parameters:
owner- the scheduler ownerbuiltId- the scheduler ID- Throws:
TimerNotFound- if the scheduler does not existIllegalTimerAccess- if the scheduler owner does not match with provided
-
-
Method Details
-
cancelUnloaded
Notice when the timer has been stopped because its source has been also unloaded- Parameters:
status- the notice unloaded status- Returns:
- this instance
-
cancel
public void cancel()Cancel the scheduler- Specified by:
cancelin classSimpleScheduler
-
pause
public void pause()Pause the scheduler- Specified by:
pausein classSimpleScheduler
-
start
Start the scheduler- Specified by:
startin classSimpleScheduler- Throws:
TimerAlreadyStarted- if the scheduler is already started
-
restart
public void restart()Restart the scheduler- Specified by:
restartin classSimpleScheduler
-
updateAutoRestart
Set if the timer should auto restart when it ends- Specified by:
updateAutoRestartin classSimpleScheduler- Parameters:
status- if the timer should auto restart- Returns:
- this instance
-
withPeriod
Set the timer update period- Specified by:
withPeriodin classSimpleScheduler- Parameters:
time- the period- Returns:
- this instance
-
multiThreading
Set if the timer runs on another thread- Specified by:
multiThreadingin classSimpleScheduler- Parameters:
status- if the timer has multi-threading- Returns:
- this instance
-
exactSecondPeriodAction
Add an action to perform when the timer reaches the specified second- Specified by:
exactSecondPeriodActionin classSimpleScheduler- Parameters:
time- the secondtask- the action to perform- Returns:
- this instance
-
exactPeriodAction
Add an action to perform when the timer reaches the specified millisecond- Specified by:
exactPeriodActionin classSimpleScheduler- Parameters:
time- the millisecondtask- the action to perform- Returns:
- this instance
-
secondChangeAction
Add an action when the timer passes a second- Specified by:
secondChangeActionin classSimpleScheduler- Parameters:
action- the action to perform- Returns:
- this instance
-
periodChangeAction
Add an action when the timer passes a millisecond- Specified by:
periodChangeActionin classSimpleScheduler- Parameters:
action- the action to perform- Returns:
- this instance
-
cancelAction
Set the action to perform when the timer is cancelled- Specified by:
cancelActionin classSimpleScheduler- Parameters:
action- the action to perform- Returns:
- this instance
-
pauseAction
Set the action to perform when the timer is paused- Specified by:
pauseActionin classSimpleScheduler- Parameters:
action- the action to perform- Returns:
- this instance
-
startAction
Set the action to perform when the timer is started- Specified by:
startActionin classSimpleScheduler- Parameters:
task- the action to perform- Returns:
- this instance
-
endAction
Set the action to perform when the timer is completely ended- Specified by:
endActionin classSimpleScheduler- Parameters:
task- the action to perform- Returns:
- this instance
-
restartAction
Set the action to perform when the timer is restarted- Specified by:
restartActionin classSimpleScheduler- Parameters:
task- the action to perform- Returns:
- this instance
-
conditionalAction
public SimpleScheduler conditionalAction(TimeCondition condition, int condition_value, Consumer<Integer> action)Add a conditional action- Specified by:
conditionalActionin classSimpleScheduler- Parameters:
condition- the condition that the timer must completecondition_value- the timer secondaction- the action to perform- Returns:
- this instance
-
conditionalPeriodAction
public SimpleScheduler conditionalPeriodAction(TimeCondition condition, long condition_value, Consumer<Long> action)Add a conditional action- Specified by:
conditionalPeriodActionin classSimpleScheduler- Parameters:
condition- the condition that the timer must completecondition_value- the timer millisecondaction- the action to perform- Returns:
- this instance
-
isCancelled
public boolean isCancelled()Get if the timer is cancelled- Specified by:
isCancelledin classSimpleScheduler- Returns:
- if the timer is cancelled
-
isRunning
public boolean isRunning()Get if the timer is running- Specified by:
isRunningin classSimpleScheduler- Returns:
- if the timer is running
-
isPaused
public boolean isPaused()Get if the timer is paused- Specified by:
isPausedin classSimpleScheduler- Returns:
- if the timer is paused
-
autoRestart
public boolean autoRestart()Get if the timer auto restarts- Specified by:
autoRestartin classSimpleScheduler- Returns:
- if the timer starts the timer automatically when it ends
-
isMultiThreading
public boolean isMultiThreading()Get if the timer has multi-threading enabled- Specified by:
isMultiThreadingin classSimpleScheduler- Returns:
- if the timer runs on another thread
-
getOriginalTime
public long getOriginalTime()Get the timer start time- Specified by:
getOriginalTimein classSimpleScheduler- Returns:
- the timer start time
-
getPeriod
public long getPeriod()Get the timer configured period- Specified by:
getPeriodin classSimpleScheduler- Returns:
- the timer update period
-
getMillis
public long getMillis()Get the timer milliseconds- Specified by:
getMillisin classSimpleScheduler- Returns:
- the timer exact time
-