Class ModuleScheduler
java.lang.Object
ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
eu.locklogin.api.module.plugin.javamodule.ModuleScheduler
public final class ModuleScheduler
extends ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
Default simple scheduler timer
-
Constructor Summary
ConstructorsConstructorDescriptionModuleScheduler(PluginModule owner, int builtId)
Get a timer from its idModuleScheduler(PluginModule owner, Number time, boolean autoRestart)
Create a new timer -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get if the timer restarts automaticallyvoid
cancel()
Cancel the schedulerml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
cancelAction(Consumer<Long> action)
Add an action when the timer gets cancelledml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
conditionalAction(ml.karmaconfigs.api.common.timer.TimeCondition condition, int condition_value, Consumer<Integer> action)
Add a conditional task for the specified secondml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
conditionalPeriodAction(ml.karmaconfigs.api.common.timer.TimeCondition condition, long condition_value, Consumer<Long> action)
Add a condition task for the specified millisecondml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
Add an action when the timer endsml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
exactPeriodAction(long time, Runnable task)
Add an action that will be run when the timer reaches the specified timeml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
exactSecondPeriodAction(int time, Runnable task)
Add an action that will be run when the timer reaches the specified timelong
Get the timer time as millislong
Get the timer original timelong
Get the timer period timeboolean
Get if the timer has been cancelledboolean
Get if the timer runs in another threadboolean
isPaused()
Get if the timer is pausedboolean
Get if the timer is runningml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
multiThreading(boolean status)
Set if the timer runs in another threadvoid
pause()
Pause the schedulerml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
pauseAction(Consumer<Long> action)
Add an action when the timer gets pausedml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
periodChangeAction(Consumer<Long> action)
Add an action whenever the period changes the timevoid
restart()
Restart the schedulerml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
restartAction(Runnable task)
Add a task when the timer gets restartedml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
secondChangeAction(Consumer<Integer> action)
Add an action whenever a second changesvoid
start()
Start the schedulerml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
startAction(Runnable task)
Add an action when the timer startsml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
updateAutoRestart(boolean status)
Update auto restart configurationml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
withPeriod(Number time)
Set the scheduler periodMethods inherited from class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
cancelFor, format, getId, getSource, getTime, requestAsync, requestSync, timeLeft
-
Constructor Details
-
ModuleScheduler
Create a new timer- Parameters:
owner
- the timer ownertime
- the timer timeautoRestart
- if the timer should auto restart
-
ModuleScheduler
public ModuleScheduler(PluginModule owner, int builtId) throws ml.karmaconfigs.api.common.timer.scheduler.errors.TimerNotFound, ml.karmaconfigs.api.common.timer.scheduler.errors.IllegalTimerAccessGet a timer from its id- Parameters:
owner
- the source that is trying to access the timerbuiltId
- the timer id- Throws:
ml.karmaconfigs.api.common.timer.scheduler.errors.TimerNotFound
- if the timer can't beml.karmaconfigs.api.common.timer.scheduler.errors.IllegalTimerAccess
- if the timer is owned by other source
-
-
Method Details
-
cancel
public final void cancel()Cancel the scheduler- Specified by:
cancel
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
-
pause
public final void pause()Pause the scheduler- Specified by:
pause
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
-
start
public final void start() throws ml.karmaconfigs.api.common.timer.scheduler.errors.TimerAlreadyStartedStart the scheduler- Specified by:
start
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Throws:
ml.karmaconfigs.api.common.timer.scheduler.errors.TimerAlreadyStarted
- if the timer is already started
-
restart
public final void restart()Restart the scheduler- Specified by:
restart
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
-
updateAutoRestart
public ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler updateAutoRestart(boolean status)Update auto restart configuration- Specified by:
updateAutoRestart
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
status
- the auto restart status- Returns:
- the simple scheduler instance
-
withPeriod
Set the scheduler period- Specified by:
withPeriod
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
time
- the scheduler period time- Returns:
- the simple scheduler instance
-
multiThreading
public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler multiThreading(boolean status)Set if the timer runs in another thread- Specified by:
multiThreading
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
status
- if the timer should run in another thread- Returns:
- the simple scheduler instance
-
exactSecondPeriodAction
public ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler exactSecondPeriodAction(int time, Runnable task)Add an action that will be run when the timer reaches the specified time- Specified by:
exactSecondPeriodAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
time
- the timetask
- the task to run- Returns:
- the simple scheduler instance
-
exactPeriodAction
public ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler exactPeriodAction(long time, Runnable task)Add an action that will be run when the timer reaches the specified time- Specified by:
exactPeriodAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
time
- the timetask
- the task to run- Returns:
- the simple scheduler instance
-
secondChangeAction
public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler secondChangeAction(Consumer<Integer> action)Add an action whenever a second changes- Specified by:
secondChangeAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
action
- the action to run- Returns:
- the simple scheduler instance
-
periodChangeAction
public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler periodChangeAction(Consumer<Long> action)Add an action whenever the period changes the time- Specified by:
periodChangeAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
action
- the action to run- Returns:
- the simple scheduler instance
-
cancelAction
public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler cancelAction(Consumer<Long> action)Add an action when the timer gets cancelled- Specified by:
cancelAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
action
- the action to run- Returns:
- the simple scheduler instance
-
pauseAction
public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler pauseAction(Consumer<Long> action)Add an action when the timer gets paused- Specified by:
pauseAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
action
- the action to run- Returns:
- the simple scheduler instance
-
startAction
Add an action when the timer starts- Specified by:
startAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
task
- the task to run- Returns:
- the simple scheduler instance
-
endAction
Add an action when the timer ends- Specified by:
endAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
task
- the task to run- Returns:
- the simple scheduler instance
-
restartAction
public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler restartAction(Runnable task)Add a task when the timer gets restarted- Specified by:
restartAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
task
- the task to run- Returns:
- the simple scheduler instance
-
conditionalAction
public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler conditionalAction(ml.karmaconfigs.api.common.timer.TimeCondition condition, int condition_value, Consumer<Integer> action)Add a conditional task for the specified second- Specified by:
conditionalAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
condition
- the conditioncondition_value
- the secondaction
- the action to run- Returns:
- the simple scheduler instance
-
conditionalPeriodAction
public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler conditionalPeriodAction(ml.karmaconfigs.api.common.timer.TimeCondition condition, long condition_value, Consumer<Long> action)Add a condition task for the specified millisecond- Specified by:
conditionalPeriodAction
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Parameters:
condition
- the conditioncondition_value
- the exact second as millisecondaction
- the action to run- Returns:
- the simple scheduler instance
-
isCancelled
public final boolean isCancelled()Get if the timer has been cancelled- Specified by:
isCancelled
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Returns:
- if the timer has been cancelled
-
isRunning
public final boolean isRunning()Get if the timer is running- Specified by:
isRunning
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Returns:
- if the timer is running
-
isPaused
public final boolean isPaused()Get if the timer is paused- Specified by:
isPaused
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Returns:
- if the timer is paused
-
autoRestart
public boolean autoRestart()Get if the timer restarts automatically- Specified by:
autoRestart
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Returns:
- if the timer restarts automatically
-
isMultiThreading
public boolean isMultiThreading()Get if the timer runs in another thread- Specified by:
isMultiThreading
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Returns:
- if the timer runs in another thread
-
getOriginalTime
public final long getOriginalTime()Get the timer original time- Specified by:
getOriginalTime
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Returns:
- the timer original time
-
getPeriod
public final long getPeriod()Get the timer period time- Specified by:
getPeriod
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Returns:
- the timer period time
-
getMillis
public final long getMillis()Get the timer time as millis- Specified by:
getMillis
in classml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
- Returns:
- the timer time as millis
-