Interface PluginTask.Builder
- Enclosing interface:
- PluginTask<V>
public static interface PluginTask.Builder
A helper object for building and scheduling a
PluginTask.
final PluginScheduler scheduler = Distributor.get().getPluginScheduler();
final MindustryPlugin plugin = ...;
// Warn the players the server is close in 5 minutes.
Groups.player.each(p -> p.sendMessage("The server will restart in 5 minutes."));
// Now schedule the closing task.
scheduler.schedule(plugin).delay(5L, MindustryTimeUnit.MINUTES).execute(() -> Core.app.exit());
-
Method Summary
Modifier and TypeMethodDescriptionasync(boolean async) Set the task execution mode.delay(long delay, MindustryTimeUnit unit) Run the task after a delay.default PluginTask.Builderdelay(TemporalAmount delay) Run the task after a delay.Build and schedule the task with the given task.execute(Consumer<Cancellable> consumer) Build and schedule the task with the given task.<V> PluginTask<V>Build and schedule the task with the given task.repeat(long interval, MindustryTimeUnit unit) Run the task periodically with a fixed interval.default PluginTask.Builderrepeat(TemporalAmount interval) Run the task periodically with a fixed interval.
-
Method Details
-
async
Set the task execution mode.- Parameters:
async- whether the task should run asynchronously.- Returns:
- this builder.
-
delay
Run the task after a delay.- Parameters:
delay- the delay.unit- the time unit of the delay.- Returns:
- this builder.
-
delay
Run the task after a delay.- Parameters:
delay- the delay.- Returns:
- this builder.
-
repeat
Run the task periodically with a fixed interval. Stops the periodic execution if an exception is thrown.- Parameters:
interval- the interval between the end of the last execution and the start of the next.unit- the time unit of the interval.- Returns:
- this builder.
-
repeat
Run the task periodically with a fixed interval. Stops the periodic execution if an exception is thrown.- Parameters:
interval- the interval between the end of the last execution and the start of the next.- Returns:
- this builder.
-
execute
Build and schedule the task with the given task.- Parameters:
runnable- the task to run.- Returns:
- a new plugin task.
-
execute
Build and schedule the task with the given task.- Parameters:
consumer- the task to run, with a cancellable object to stop the task if it's periodic.- Returns:
- a new plugin task.
-
execute
Build and schedule the task with the given task.- Parameters:
supplier- the task to run, with an output value. Won't output any result value if the task is periodic.- Returns:
- a new plugin task.
-