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

    Constructors
    Constructor
    Description
    ModuleScheduler​(PluginModule owner, int builtId)
    Get a timer from its id
    ModuleScheduler​(PluginModule owner, Number time, boolean autoRestart)
    Create a new timer
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Get if the timer restarts automatically
    void
    Cancel the scheduler
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    Add an action when the timer gets cancelled
    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
    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
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    Add an action when the timer ends
    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
    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
    long
    Get the timer time as millis
    long
    Get the timer original time
    long
    Get the timer period time
    boolean
    Get if the timer has been cancelled
    boolean
    Get if the timer runs in another thread
    boolean
    Get if the timer is paused
    boolean
    Get if the timer is running
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    multiThreading​(boolean status)
    Set if the timer runs in another thread
    void
    Pause the scheduler
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    Add an action when the timer gets paused
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    Add an action whenever the period changes the time
    void
    Restart the scheduler
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    Add a task when the timer gets restarted
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    Add an action whenever a second changes
    void
    Start the scheduler
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    Add an action when the timer starts
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    updateAutoRestart​(boolean status)
    Update auto restart configuration
    ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    withPeriod​(Number time)
    Set the scheduler period

    Methods inherited from class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler

    cancelFor, format, getId, getSource, getTime, requestAsync, requestSync, timeLeft

    Methods inherited from class java.lang.Object

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

    • ModuleScheduler

      public ModuleScheduler(PluginModule owner, Number time, boolean autoRestart)
      Create a new timer
      Parameters:
      owner - the timer owner
      time - the timer time
      autoRestart - 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.IllegalTimerAccess
      Get a timer from its id
      Parameters:
      owner - the source that is trying to access the timer
      builtId - the timer id
      Throws:
      ml.karmaconfigs.api.common.timer.scheduler.errors.TimerNotFound - if the timer can't be
      ml.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 class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    • pause

      public final void pause()
      Pause the scheduler
      Specified by:
      pause in class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
    • start

      public final void start() throws ml.karmaconfigs.api.common.timer.scheduler.errors.TimerAlreadyStarted
      Start the scheduler
      Specified by:
      start in class ml.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 class ml.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 class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
      Parameters:
      status - the auto restart status
      Returns:
      the simple scheduler instance
    • withPeriod

      public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler withPeriod(Number time)
      Set the scheduler period
      Specified by:
      withPeriod in class ml.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 class ml.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 class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
      Parameters:
      time - the time
      task - 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 class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
      Parameters:
      time - the time
      task - 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 class ml.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 class ml.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 class ml.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 class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
      Parameters:
      action - the action to run
      Returns:
      the simple scheduler instance
    • startAction

      public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler startAction(Runnable task)
      Add an action when the timer starts
      Specified by:
      startAction in class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
      Parameters:
      task - the task to run
      Returns:
      the simple scheduler instance
    • endAction

      public final ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler endAction(Runnable task)
      Add an action when the timer ends
      Specified by:
      endAction in class ml.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 class ml.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 class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
      Parameters:
      condition - the condition
      condition_value - the second
      action - 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 class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
      Parameters:
      condition - the condition
      condition_value - the exact second as millisecond
      action - 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 class ml.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 class ml.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 class ml.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 class ml.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 class ml.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 class ml.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 class ml.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 class ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
      Returns:
      the timer time as millis