1 minute estimated read time

Countdown tasks

Below is an example of a countdown task that will run on your server’s scheduler (main server thread).
Use countdown tasks for a more structured way of creating server-synchronous countdowns.

The example shown below will define a countdown of 10 seconds, every 1 second the countdown will decrease.

MyCountdownTask.java
@VitalCountdownTask.Info(interval = 1_000, countdown = 10)
public class MyCountdownTask extends VitalCountdownTask.Spigot {
    public MyCountdownTask(JavaPlugin plugin) {
        super(plugin);
    }

    @Override
    public void onTick() {
        for (final var player : Bukkit.getOnlinePlayers()) {
            player.sendMessage("Countdown tick.");
        }
    }

    @Override
    public void onExpire() {
        for (final var player : Bukkit.getOnlinePlayers()) {
            player.sendMessage("Countdown has expired");
        }
    }
}

Found an issue?

Help us improve the documentation by reporting typos, missing information, or anything confusing.

Don't worry, we will auto-fill most of the annoying fields.

Create GitHub issue

This site and the Vital framework were built with ❤️ by Mike Neumann