Class PluginScheduler<T,Z>
java.lang.Object
com.olziedev.playerwarps.api.scheduler.PluginScheduler<T,Z>
- Type Parameters:
T
- The type of plugin task.Z
- The type of object to get the plugin task from.
This class is used to schedule tasks for the plugin.
-
Constructor Summary
ConstructorDescriptionPluginScheduler
(JavaPlugin plugin) This constructor is used to create a new plugin scheduler. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
This method is used to cancel all the tasks.abstract void
getChunkAsync
(Location location, Consumer<BukkitChunk> task) This method is used to get a chunk asynchronously when possible.runSingleTaskAsync
(Consumer<PluginTask> task) This method is used to run a task on a single thread.abstract void
Ths method is used to run a task on the main thread.abstract PluginTask
runTaskAsync
(Consumer<PluginTask> task) This method is used to run a task asynchronously.abstract void
runTaskAtEntity
(Entity entity, Consumer<PluginTask> task) This method is used to run a task at a specific entity.abstract PluginTask
runTaskAtEntityLater
(Entity entity, Consumer<PluginTask> task, long delay) This method is used to run a task at a specific entity after a delay.abstract PluginTask
runTaskAtEntityTimer
(Entity entity, Consumer<PluginTask> task, long delay, long period) This method is used to run a task at a specific entity after a delay and then repeat it.abstract void
runTaskAtLocation
(Chunk chunk, Consumer<PluginTask> task) This method is used to run a task at a specific chunk.void
runTaskAtLocation
(Location location, Consumer<PluginTask> task) This method is used to run a task at a specific location.abstract PluginTask
runTaskAtLocationLater
(Chunk chunk, Consumer<PluginTask> task, long delay) This method is used to run a task at a specific chunk after a delay.runTaskAtLocationLater
(Location location, Consumer<PluginTask> task, long delay) This method is used to run a task at a specific location after a delay.abstract PluginTask
runTaskAtLocationTimer
(Chunk chunk, Consumer<PluginTask> task, long delay, long period) This method is used to run a task at a specific chunk after a delay and then repeat it.runTaskAtLocationTimer
(Location location, Consumer<PluginTask> task, long delay, long period) This method is used to run a task at a specific location after a delay and then repeat it.abstract PluginTask
runTaskLater
(Consumer<PluginTask> task, long delay) This method is used to run a task on the main thread after a delay.abstract PluginTask
runTaskLaterAsync
(Consumer<PluginTask> task, long delay) This method is used to run a task asynchronously after a delay.abstract PluginTask
runTaskTimer
(Consumer<PluginTask> task, long delay, long period) This method is used to run a task on the main thread after a delay and then repeat it.abstract PluginTask
runTaskTimerAsync
(Consumer<PluginTask> task, long delay, long period) This method is used to run a task asynchronously after a delay and then repeat it.static void
This method is used to schedule a runnable to run after a delay.static void
This method is used to setup the executors.abstract void
teleportAsync
(Player player, Location location, Consumer<Boolean> task, PlayerTeleportEvent.TeleportCause teleportCause) This method is used to teleport a player to a location asynchronously when possible.
-
Constructor Details
-
PluginScheduler
This constructor is used to create a new plugin scheduler.- Parameters:
plugin
- The plugin to use.
-
-
Method Details
-
runTask
Ths method is used to run a task on the main thread.- Parameters:
task
- The task to run.
-
runTaskAsync
This method is used to run a task asynchronously.- Parameters:
task
- The task to run.- Returns:
- The task that was run.
-
runSingleTaskAsync
This method is used to run a task on a single thread.- Parameters:
task
- The task to run.- Returns:
- The task that was run.
-
runTaskLater
This method is used to run a task on the main thread after a delay.- Parameters:
task
- The task to run.delay
- The delay before the task is run.- Returns:
- The task that was run.
-
runTaskLaterAsync
This method is used to run a task asynchronously after a delay.- Parameters:
task
- The task to run.delay
- The delay before the task is run.- Returns:
- The task that was run.
-
runTaskTimer
This method is used to run a task on the main thread after a delay and then repeat it.- Parameters:
task
- The task to run.delay
- The delay before the task is run.period
- The period between each run.- Returns:
- The task that was run.
-
runTaskTimerAsync
This method is used to run a task asynchronously after a delay and then repeat it.- Parameters:
task
- The task to run.delay
- The delay before the task is run.period
- The period between each run.- Returns:
- The task that was run.
-
runTaskAtLocation
This method is used to run a task at a specific location.- Parameters:
location
- The location to run the task at.task
- The task to run.
-
runTaskAtLocationLater
This method is used to run a task at a specific location after a delay.- Parameters:
location
- The location to run the task at.task
- The task to run.delay
- The delay before the task is run.- Returns:
- The task that was run.
-
runTaskAtLocationTimer
public PluginTask runTaskAtLocationTimer(Location location, Consumer<PluginTask> task, long delay, long period) This method is used to run a task at a specific location after a delay and then repeat it.- Parameters:
location
- The location to run the task at.task
- The task to run.delay
- The delay before the task is run.period
- The period between each run.- Returns:
- The task that was run.
-
runTaskAtLocation
This method is used to run a task at a specific chunk.- Parameters:
chunk
- The chunk to run the task at.task
- The task to run.
-
runTaskAtLocationLater
public abstract PluginTask runTaskAtLocationLater(Chunk chunk, Consumer<PluginTask> task, long delay) This method is used to run a task at a specific chunk after a delay.- Parameters:
chunk
- The chunk to run the task at.task
- The task to run.delay
- The delay before the task is run.- Returns:
- The task that was run.
-
runTaskAtLocationTimer
public abstract PluginTask runTaskAtLocationTimer(Chunk chunk, Consumer<PluginTask> task, long delay, long period) This method is used to run a task at a specific chunk after a delay and then repeat it.- Parameters:
chunk
- The chunk to run the task at.task
- The task to run.delay
- The delay before the task is run.period
- The period between each run.- Returns:
- The task that was run.
-
runTaskAtEntity
This method is used to run a task at a specific entity.- Parameters:
entity
- The entity to run the task at.task
- The task to run.
-
runTaskAtEntityLater
public abstract PluginTask runTaskAtEntityLater(Entity entity, Consumer<PluginTask> task, long delay) This method is used to run a task at a specific entity after a delay.- Parameters:
entity
- The entity to run the task at.task
- The task to run.delay
- The delay before the task is run.- Returns:
- The task that was run.
-
runTaskAtEntityTimer
public abstract PluginTask runTaskAtEntityTimer(Entity entity, Consumer<PluginTask> task, long delay, long period) This method is used to run a task at a specific entity after a delay and then repeat it.- Parameters:
entity
- The entity to run the task at.task
- The task to run.delay
- The delay before the task is run.period
- The period between each run.- Returns:
- The task that was run.
-
teleportAsync
public abstract void teleportAsync(Player player, Location location, Consumer<Boolean> task, PlayerTeleportEvent.TeleportCause teleportCause) This method is used to teleport a player to a location asynchronously when possible.- Parameters:
player
- The player to teleport.location
- The location to teleport the player to.task
- The task to run after the teleport.teleportCause
- The cause of the teleport.
-
getChunkAsync
This method is used to get a chunk asynchronously when possible.- Parameters:
location
- The location to get the chunk from.task
- The task to run after the chunk is retrieved.
-
cancelAllTasks
public abstract void cancelAllTasks()This method is used to cancel all the tasks. -
schedule
This method is used to schedule a runnable to run after a delay.- Parameters:
runnable
- The runnable to run.date
- The date to run the runnable.
-
setExecutors
public static void setExecutors()This method is used to setup the executors.
-