-
Notifications
You must be signed in to change notification settings - Fork 0
Timer : Async
Xenxia edited this page Feb 27, 2021
·
1 revision
import fr.cheeseGrinder.bukkitTimer.Time;
import fr.cheeseGrinder.bukkitTimer.Timer;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class TestTimer {
private final Timer timer;
public TestTimer(JavaPlugin plugin) {
this.timer = new Timer(plugin);
// you can also set a default template for formatting the time.
this.timer = new Timer(plugin, "0.0");
}
public void runAsyncTimer() {
timer.runAsync(5f, Time.EVERY_0_70, (timeLeft) -> {
Bukkit.broadcastMessage("time left -> " + timeLeft);
});
// Another way to write a async timer
timer.runAsync(5f, Time.EVERY_0_80, () -> {
// Do some stuff
});
timer.runAsync(5f, Time.EVERY_0_90);
// You can add a uuid to make timer for specific entity
timer.runAsync(5f, Time.EVERY_1_00, player.getUniqueId(), (timeLeft) -> {
Bukkit.broadcastMessage("time left -> " + timeLeft);
});
timer.runAsync(5f, Time.EVERY_0_50, player.getUniqueId(), () -> {
// Do some stuff
});
timer.runAsync(5f, Time.EVERY_0_50, player.getUniqueId());
}
}