mc-TimesAPI
Last updated
Last updated
Say goodbye to complex Bukkit schedulers and hello to human-readable task scheduling!
TimesAPI is a modern, lightweight Java scheduling library that transforms how you handle scheduled tasks in your Spigot plugins. Instead of wrestling with tick calculations and complex scheduler syntax, you can now schedule tasks using natural language like:
⢠"EVERYDAY @ 18:00" - Daily server restart warning ⢠"EVERY MON,WED,FRI @ 12:00" - Periodic world saves ⢠"EVERY 30 MINUTES" - Regular cleanup tasks ⢠"WEEKDAYS @ 09:00" - Weekday-only announcements
// Confusing tick calculations and verbose syntax
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
// Daily restart warning
}, 20L * 60 * 60 * 24, 20L * 60 * 60 * 24); // 24 hours in ticks - confusing!
TimesAPI scheduler = new TimesAPI();
scheduler.schedule("EVERYDAY @ 18:00", () -> {
Bukkit.broadcastMessage("§6Server restart in 1 hour!");
});
public class ServerTasks {
@Schedule("EVERYDAY @ 06:00")
public void dailyBackup() {
backupPlayerData();
backupWorldData();
}
@Schedule(value = "EVERY 5 MINUTES", async = true)
public void cleanupEntities() {
// Heavy cleanup task runs asynchronously
cleanupLaggyEntities();
}
@Schedule("WEEKDAYS @ 16:00")
public void schoolHoursEnd() {
Bukkit.broadcastMessage("§a[SCHOOL] School hours ended! Welcome back students!");
}
}
// Register in your plugin
TimesAPI scheduler = new TimesAPI();
scheduler.registerScheduledClass(new ServerTasks());
// Task Management:
// Cancel tasks dynamically
String taskId = scheduler.schedule("EVERY HOUR", () -> {
if (serverMaintenanceMode) {
return; // Skip during maintenance
}
performHourlyTasks();
}).get().getId();
// Cancel when needed
scheduler.cancelTask(taskId);
ā No more tick calculations - use real-world time ā Human-readable scheduling syntax ā Thread-safe and performance optimized ā Zero configuration required ā Perfect for both simple and complex scheduling needs ā Lightweight with 0 dependency! ā Async support for heavy operations ā Built-in error handling and recovery