geforkt von Mirrors/Velocity
Add Duration methods to TaskBuilder (#445)
Dieser Commit ist enthalten in:
Ursprung
7ba2318506
Commit
54474d7100
@ -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.
|
||||
*
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren