Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit eb5b032

Browse files
committed
Read.me Update
1 parent aa05c51 commit eb5b032

File tree

2 files changed

+79
-3
lines changed

2 files changed

+79
-3
lines changed

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,80 @@ fun onJoin(e: PlayerJoinEvent){
239239
public void onJoin(PlayerJoinEvent e){
240240
//Code
241241
}
242+
```
243+
244+
## Scheduler
245+
246+
> [!CAUTION]
247+
> KOTLIN ONLY
248+
249+
> [!Note]
250+
> TimeUntil class was taken from [TwilightAPI](https://github.com/flytegg/twilight)
251+
252+
This API makes it easier to create tasks by make methods that be accessed any were. We are going to start by running code sync and async by using this. (See below)
253+
254+
```kotlin
255+
sync {
256+
//Run sync code
257+
}
258+
259+
async {
260+
//Run async code
261+
}
262+
```
263+
264+
### Delay
265+
266+
Next is delaying a task. This is not much different. (See below)
267+
268+
```kotlin
269+
delay(20) {
270+
//This task will be run in 20 ticks
271+
}
272+
273+
delay(20, true) {
274+
//This task will be run in 20 ticks async
275+
}
276+
277+
delay(1, TimeUnit.SECONDS, false){
278+
//This task will be run is 20 ticks sync
279+
}
280+
```
281+
282+
### Repeating
283+
284+
Last one is creating repeating tasks. With this you will be able to give in how many times the task will run as wel. (See below)
285+
286+
```kotlin
287+
repeatingTask(1) {
288+
//This will run every tick
289+
}
290+
291+
repeatingTask(20, 5){
292+
//This will run every 20 ticks 5 times
293+
}
294+
295+
repeatingTask(1, true){
296+
//This will run every tick async
297+
}
298+
299+
repeatingTask(20, true, 5){
300+
//This will run every 20 ticks 5 times async
301+
}
302+
303+
repeatingTask(1, TimeUnit.SECONDS){
304+
//This will run every second
305+
}
306+
307+
repeatingTask(1, TimeUnit.SECONDS, 5){
308+
//This will run every second 5 times
309+
}
310+
311+
repeatingTask(1, TimeUnit.SECONDS, true){
312+
//This will run every second async
313+
}
314+
315+
repeatingTask(1, TimeUnit.SECONDS, 5, true){
316+
//This will run every second 5 times async
317+
}
242318
```

src/main/java/com/redmagic/undefinedapi/UndefinedAPI.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package com.redmagic.undefinedapi
22

33
import com.redmagic.undefinedapi.event.EventManager
44
import com.redmagic.undefinedapi.menu.MenuManager
5+
import com.redmagic.undefinedapi.scheduler.TimeUnit
6+
import com.redmagic.undefinedapi.scheduler.delay
57
import com.redmagic.undefinedapi.scheduler.repeatingTask
6-
import org.bukkit.Bukkit
78
import org.bukkit.plugin.java.JavaPlugin
8-
import java.util.concurrent.TimeUnit
9-
import kotlin.random.Random
9+
1010

1111
class UndefinedAPI(javaPlugin: JavaPlugin) {
1212

0 commit comments

Comments
 (0)