Class SimpleScheduler

java.lang.Object
ml.karmaconfigs.api.common.timer.scheduler.SimpleScheduler
Direct Known Subclasses:
SourceSecondsTimer, SourceSimpleTimer

public abstract class SimpleScheduler extends Object
Karma simple scheduler
  • Constructor Details

    • SimpleScheduler

      public SimpleScheduler(KarmaSource owner)
      Initialize the scheduler
      Parameters:
      owner - the scheduler source
  • Method Details

    • cancelFor

      public static void cancelFor(KarmaSource owner)
      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

      public abstract void start() throws TimerAlreadyStarted
      Start the scheduler
      Throws:
      TimerAlreadyStarted - if the scheduler is already started
    • restart

      public abstract void restart()
      Restart the scheduler
    • updateAutoRestart

      public abstract SimpleScheduler updateAutoRestart(boolean paramBoolean)
      Set if the timer should auto restart when it ends
      Parameters:
      paramBoolean - if the timer should auto restart
      Returns:
      this instance
    • withPeriod

      public abstract SimpleScheduler withPeriod(Number paramNumber)
      Set the timer update period
      Parameters:
      paramNumber - the period
      Returns:
      this instance
    • multiThreading

      public abstract SimpleScheduler multiThreading(boolean paramBoolean)
      Set if the timer runs on another thread
      Parameters:
      paramBoolean - if the timer has multi-threading
      Returns:
      this instance
    • exactSecondPeriodAction

      public abstract SimpleScheduler exactSecondPeriodAction(int paramInt, Runnable paramRunnable)
      Add an action to perform when the timer reaches the specified second
      Parameters:
      paramInt - the second
      paramRunnable - the action to perform
      Returns:
      this instance
    • exactPeriodAction

      public abstract SimpleScheduler exactPeriodAction(long paramLong, Runnable paramRunnable)
      Add an action to perform when the timer reaches the specified millisecond
      Parameters:
      paramLong - the millisecond
      paramRunnable - the action to perform
      Returns:
      this instance
    • secondChangeAction

      public abstract SimpleScheduler secondChangeAction(Consumer<Integer> paramConsumer)
      Add an action when the timer passes a second
      Parameters:
      paramConsumer - the action to perform
      Returns:
      this instance
    • periodChangeAction

      public abstract SimpleScheduler periodChangeAction(Consumer<Long> paramConsumer)
      Add an action when the timer passes a millisecond
      Parameters:
      paramConsumer - the action to perform
      Returns:
      this instance
    • cancelAction

      public abstract SimpleScheduler cancelAction(Consumer<Long> paramConsumer)
      Set the action to perform when the timer is cancelled
      Parameters:
      paramConsumer - the action to perform
      Returns:
      this instance
    • pauseAction

      public abstract SimpleScheduler pauseAction(Consumer<Long> paramConsumer)
      Set the action to perform when the timer is paused
      Parameters:
      paramConsumer - the action to perform
      Returns:
      this instance
    • startAction

      public abstract SimpleScheduler startAction(Runnable paramRunnable)
      Set the action to perform when the timer is started
      Parameters:
      paramRunnable - the action to perform
      Returns:
      this instance
    • endAction

      public abstract SimpleScheduler endAction(Runnable paramRunnable)
      Set the action to perform when the timer is completely ended
      Parameters:
      paramRunnable - the action to perform
      Returns:
      this instance
    • restartAction

      public abstract SimpleScheduler restartAction(Runnable paramRunnable)
      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 complete
      paramInt - the timer second
      paramConsumer - 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 complete
      paramLong - the timer millisecond
      paramConsumer - 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

      public final long getTime(TimeUnit unit)
      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

      public final String format(TimeUnit unit, String name)
      Format the current timer time
      Parameters:
      unit - the time unit
      name - the unit name
      Returns:
      the formatted timer time
    • timeLeft

      public final String timeLeft(boolean millis)
      Get the timer time left to be finished
      Parameters:
      millis - include the milliseconds on the format
      Returns:
      the time left format
    • requestSync

      @Deprecated public void requestSync(Runnable action)
      Deprecated.
      Request a synchronous task
      Parameters:
      action - the action to perform
    • requestAsync

      @Deprecated public void requestAsync(Runnable action)
      Deprecated.
      Request an asynchronous task
      Parameters:
      action - the action to perform
    • getSource

      public final KarmaSource getSource()
      Get the scheduler source
      Returns:
      the scheduler source
    • getId

      public final int getId()
      Get the scheduler ID
      Returns:
      the scheduler ID