Package one.tranic.irs
Class PluginSchedulerBuilder
java.lang.Object
one.tranic.irs.PluginSchedulerBuilder
Builder class for scheduling tasks in a Bukkit or Folia environment.
Supports synchronous and asynchronous execution with various scheduling options.
Usage example:
PluginSchedulerBuilder.builder(plugin)
.sync()
.task(() -> Bukkit.getLogger().info("Task executed!"))
.delayTicks(20L)
.run();
-
Constructor Summary
ConstructorsConstructorDescriptionPluginSchedulerBuilder(org.bukkit.plugin.Plugin plugin) Constructs a newPluginSchedulerBuilderfor the given plugin. -
Method Summary
Modifier and TypeMethodDescriptionasync()Configures the task to run asynchronously.static PluginSchedulerBuilderbuilder(org.bukkit.plugin.Plugin plugin) Creates a new instance ofPluginSchedulerBuilder.voidcancelTasks(org.bukkit.plugin.Plugin plugin) delayTicks(long delayTicks) Sets the initial delay in ticks before the task is executed.period(long period) Sets the period in ticks between consecutive executions of the task.TaskImpl<org.bukkit.plugin.Plugin>run()Builds and schedules the task based on the configured parameters.sync()Configures the task to run synchronously.sync(@NotNull org.bukkit.entity.Entity entity) Configures the task to run synchronously on the specified entity.sync(@NotNull org.bukkit.Location location) Configures the task to run synchronously at the specified location.Sets the task to be executed.
-
Constructor Details
-
PluginSchedulerBuilder
public PluginSchedulerBuilder(org.bukkit.plugin.Plugin plugin) Constructs a newPluginSchedulerBuilderfor the given plugin. Automatically detects the platform to adjust behavior for Folia or Spigot.- Parameters:
plugin- the plugin instance to associate with this scheduler builder
-
-
Method Details
-
builder
Creates a new instance ofPluginSchedulerBuilder.- Parameters:
plugin- the plugin instance to associate with this scheduler builder- Returns:
- a new
PluginSchedulerBuilderinstance
-
cancelTasks
public void cancelTasks(org.bukkit.plugin.Plugin plugin) -
sync
Configures the task to run synchronously.- Returns:
- this builder instance for method chaining
-
sync
Configures the task to run synchronously at the specified location.- Parameters:
location- the location where the task will execute synchronously- Returns:
- this builder instance for method chaining
-
sync
Configures the task to run synchronously on the specified entity.- Parameters:
entity- the entity where the task will execute synchronously- Returns:
- this builder instance for method chaining
-
async
Configures the task to run asynchronously.- Returns:
- this builder instance for method chaining
-
task
Sets the task to be executed.- Parameters:
runnable- the task to execute- Returns:
- this builder instance for method chaining
-
delayTicks
Sets the initial delay in ticks before the task is executed.- Parameters:
delayTicks- the number of ticks to delay- Returns:
- this builder instance for method chaining
-
period
Sets the period in ticks between consecutive executions of the task.- Parameters:
period- the number of ticks between executions- Returns:
- this builder instance for method chaining
-
run
Builds and schedules the task based on the configured parameters.- Returns:
- a
TaskImplrepresenting the scheduled task - Throws:
UnsupportedOperationException- if the task is not set
-