0.1.1 | Scheduler shenanigans

This commit is contained in:
Patrick
2026-06-05 14:08:07 +02:00
parent f9fa1af963
commit dcd8c8597d
9 changed files with 302 additions and 103 deletions
+69
View File
@@ -67,4 +67,73 @@ public class main {
}
}
}
```
### Usage Scheduler (without retries)
```java
import java.time.Duration;
public class main {
public static void main(String[] args) {
LicenseScheduler scheduler = LicenseScheduler.startScheduler(
Duration.ofMinutes(5),
apiUrl,
plugin,
licenseKey,
serverId,
result -> {
if (result instanceof LicenseSuccess success) {
if (!success.valid()) {
// Handle invalid license
}
} else if (result instanceof LicenseError error) {
// Log errors if you want
}
}
);
// Later: Stop the scheduler
scheduler.stop();
}
}
```
### Usage Scheduler (with retries)
```java
import java.time.Duration;
public class main {
public static void main(String[] args) {
LicenseScheduler scheduler = LicenseScheduler.startSchedulerWithRetries(
Duration.ofMinutes(5),
apiUrl,
plugin,
licenseKey,
serverId,
3, //max retries,
Duration.ofSeconds(10), //delay between retries
result -> {
if(result instanceof LicenseSuccess success) {
if (!success.valid()) {
// Handle invalid license
}
} else if (result instanceof LicenseError error) {
// Log errors if you want
}
},
result -> {
// Called only after all retries failed
// Put your "offline" handling here
// Disable plugin or something like that
}
);
// Later: Stop the scheduler
scheduler.stop();
}
}
```