Interface Task.Builder

    • Method Detail

      • execute

        default Task.Builder execute​(Runnable runnable)
        Sets the Runnable to run when this task executes.
        Parameters:
        runnable - The actual task to run
        Returns:
        This builder, for chaining
      • execute

        Task.Builder execute​(Consumer<ScheduledTask> executor)
        Sets the consumer that runs when this task executes.
        Parameters:
        executor - The executor to run
        Returns:
        This builder, for chaining
      • delay

        default Task.Builder delay​(long delay,
                                   TemporalUnit unit)
        Sets the delay before the task runs. This delay is an initial offset, subsequent runs (when the interval is not 0) will not be offset. By default, the delay is 0.
        Parameters:
        delay - The delay in the given TemporalUnit
        unit - The unit the delay is in
        Returns:
        This builder, for chaining
        Throws:
        IllegalArgumentException - If the delay is below 0
      • delay

        default Task.Builder delay​(long delay,
                                   TimeUnit unit)
        Sets the delay before the task runs. This delay is an initial offset, subsequent runs (when the interval is not 0) will not be offset. By default, the delay is 0.
        Parameters:
        delay - The delay in the given TimeUnit
        unit - The unit the delay is in
        Returns:
        This builder, for chaining
        Throws:
        IllegalArgumentException - If the delay is below 0
      • delay

        Task.Builder delay​(Duration delay)
        Sets the delay before the task runs. This delay is an initial offset, subsequent runs (when the interval is not 0) will not be offset. By default, the delay is 0.
        Parameters:
        delay - The delay duration
        Returns:
        This builder, for chaining
        Throws:
        IllegalArgumentException - If the delay duration is below 0
      • interval

        Task.Builder interval​(Duration interval)
        Sets the interval between repetitions of the task. The task will not repeat if the interval is 0. By default, the interval is 0.

        If the scheduler detects that two tasks will overlap, the 2nd task will not be started. The next time the task is due to run, the test will be made again to determine if the previous occurrence of the task is still alive (running). As long as a previous occurrence is running no new occurrences of that specific task will start, although the scheduler will never cease in trying to start it a 2nd time.

        Parameters:
        interval - The interval duration
        Returns:
        This builder, for chaining
        Throws:
        IllegalArgumentException - If the interval is below 0
      • interval

        default Task.Builder interval​(long interval,
                                      TemporalUnit unit)
        Sets the interval between repetitions of the task. The task will not repeat if the interval is 0. By default, the interval is 0.

        If the scheduler detects that two tasks will overlap, the 2nd task will not be started. The next time the task is due to run, the test will be made again to determine if the previous occurrence of the task is still alive (running). As long as a previous occurrence is running no new occurrences of that specific task will start, although the scheduler will never cease in trying to start it a 2nd time.

        Parameters:
        interval - The interval in the given TemporalUnit
        unit - The unit the interval is in
        Returns:
        This builder, for chaining
        Throws:
        IllegalArgumentException - If the interval is below 0
      • interval

        default Task.Builder interval​(long interval,
                                      TimeUnit unit)
        Sets the interval between repetitions of the task. The task will not repeat if the interval is 0. By default, the interval is 0.

        If the scheduler detects that two tasks will overlap, the 2nd task will not be started. The next time the task is due to run, the test will be made again to determine if the previous occurrence of the task is still alive (running). As long as a previous occurrence is running no new occurrences of that specific task will start, although the scheduler will never cease in trying to start it a 2nd time.

        Parameters:
        interval - The interval in the given TimeUnit
        unit - The unit the interval is in
        Returns:
        This builder, for chaining
        Throws:
        IllegalArgumentException - If the interval is below 0
      • interval

        Task.Builder interval​(Ticks ticks)
        Sets the interval in unit ticks between repetitions of the task.
        Parameters:
        ticks - The Ticks between runs.
        Returns:
        This builder, for chaining
        Throws:
        IllegalArgumentException - If the interval is below 0
      • plugin

        Task.Builder plugin​(org.spongepowered.plugin.PluginContainer plugin)
        Sets the plugin of the task.
        Parameters:
        plugin - The plugin instance
        Returns:
        This builder, for chaining
        Throws:
        IllegalArgumentException - If the given object isn't a valid plugin