Package me.totalfreedom.service
Class Task
java.lang.Object
org.bukkit.scheduler.BukkitRunnable
me.totalfreedom.service.Task
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
BossBarTimer,ReactionTask
public abstract class Task
extends org.bukkit.scheduler.BukkitRunnable
Represents a task that can be run asynchronously or synchronously.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new task with the given name.protectedCreates a new task with the given name and delay.protectedCreates a new task with the given name, delay, and interval.protectedCreates a new task with the given name, delay, and interval.protectedCreates a new task with the given name and delay.protectedCreates a new task with the given name, delay, and interval. -
Method Summary
Methods inherited from class org.bukkit.scheduler.BukkitRunnable
cancel, getTaskId, isCancelled, runTask, runTaskAsynchronously, runTaskLater, runTaskLaterAsynchronously, runTaskTimer, runTaskTimerAsynchronously
-
Constructor Details
-
Task
Creates a new task with the given name. This will initialize a task with no initail delay and no interval.- Parameters:
name- The name of the task.
-
Task
Creates a new task with the given name, delay, and interval.
It's important to note that the delay and interval are in ticks. One tick is equal to 1/20th of a second, which means there are 20 ticks are in one second. If your interval is intended to be anything less than 20 ticks, you should use aServiceinstead.- Parameters:
name- The name of the task.delay- The delay of the task.interval- The interval of the task.
-
Task
Creates a new task with the given name and delay. This will intialize a single execute task with an initial delay before execution.- Parameters:
name- The name of the task.delay- How long the task should wait before executing.
-
Task
Creates a new task with the given name and delay. This is the same as longs, except that here, we naturally support durations which are automatically converted to ticks for you. This means that usingDuration.ofSeconds(long)will work as expected.- Parameters:
name- The name of the task.delay- How long the task should wait before executing.
-
Task
Creates a new task with the given name, delay, and interval. This is the same as longs, except that here, we naturally support durations which are automatically converted to ticks for you. This means that usingDuration.ofSeconds(long)will work as expected.- Parameters:
name- The name of the task.delay- How long the task should wait before executing.interval- How long the task should wait between executions.
-
Task
Creates a new task with the given name, delay, and interval. This method is a convenience method to use aDurationfor the interval, while also being able to specify the delay as -1L so the task does not have an initial delay before execution.- Parameters:
name- The name of the task.delay- The delay of the task.interval- The interval of the task.
-
-
Method Details
-
isRunning
public boolean isRunning()- Returns:
- True if the task is running, false otherwise.
-
getName
- Returns:
- The name of the task.
-
isRepeating
public boolean isRepeating()- Returns:
- True if the task is repeating, false otherwise.
-
isDelayed
public boolean isDelayed()- Returns:
- True if the task is delayed, false otherwise.
-
getInterval
public long getInterval()- Returns:
- The interval between each task execution.
-
getDelay
public long getDelay()- Returns:
- The initial delay before the first execution of this task.
-