# mc-TimesAPI

## 🕐 TimesAPI - Revolutionary Task Scheduling for Spigot Plugins and for Java projects!

Say goodbye to complex Bukkit schedulers and hello to human-readable task scheduling!<br>

### ❓ What is TimesAPI?

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

### ⚡ Why TimesAPI for Spigot Development?

#### Traditional Bukkit Scheduler:

```java
// 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!
```

#### With TimesAPI:

<pre class="language-java"><code class="lang-java">TimesAPI scheduler = new TimesAPI();
scheduler.schedule("EVERYDAY @ 18:00", () -> { 
<strong>    Bukkit.broadcastMessage("§6Server restart in 1 hour!");
</strong>});
</code></pre>

### ⭐ Advanced Features for Plugin Developers

#### Annotation-Based Scheduling:&#xD;

```java
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!"); 
    }
}
```

```java
// 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);
```

### ☀ Why Choose TimesAPI?

✅ 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mongenscave.com/standalone-apis/mc-timesapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
