13
0
geforkt von Mirrors/Velocity

Add Duration methods to TaskBuilder (#445)

Dieser Commit ist enthalten in:
A248 2021-04-02 01:51:54 -04:00 committet von GitHub
Ursprung 7ba2318506
Commit 54474d7100
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -7,6 +7,7 @@
package com.velocitypowered.api.scheduler;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import org.checkerframework.common.value.qual.IntRange;
@ -38,6 +39,16 @@ public interface Scheduler {
*/
TaskBuilder delay(@IntRange(from = 0) long time, TimeUnit unit);
/**
* Specifies that the task should delay its execution by the specified amount of time.
*
* @param duration the duration of the delay
* @return this builder, for chaining
*/
default TaskBuilder delay(Duration duration) {
return delay(duration.toMillis(), TimeUnit.MILLISECONDS);
}
/**
* Specifies that the task should continue running after waiting for the specified amount, until
* it is cancelled.
@ -48,6 +59,17 @@ public interface Scheduler {
*/
TaskBuilder repeat(@IntRange(from = 0) long time, TimeUnit unit);
/**
* Specifies that the task should continue running after waiting for the specified amount, until
* it is cancelled.
*
* @param duration the duration of the delay
* @return this builder, for chaining
*/
default TaskBuilder repeat(Duration duration) {
return repeat(duration.toMillis(), TimeUnit.MILLISECONDS);
}
/**
* Clears the delay on this task.
*