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()
.setTask(() -> Bukkit.getLogger().info("Task executed!"))
.setDelayTicks(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.TaskImpl<org.bukkit.plugin.Plugin>run()Builds and schedules the task based on the configured parameters.setDelayTicks(long delayTicks) Sets the initial delay in ticks before the task is executed.setPeriod(long period) Sets the period in ticks between consecutive executions of the task.Sets the task to be executed.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.
-
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
-
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
-
setTask
Sets the task to be executed.- Parameters:
runnable- the task to execute- Returns:
- this builder instance for method chaining
-
setDelayTicks
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
-
setPeriod
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
-