Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
RedMagic edited this page Apr 23, 2024 · 3 revisions

More info and source code click here

Inside the default spigotapi you use tasks to delay, repeat or run a task async. Inside the UndefinedAPI is even quicker to create tasks. Lets first give a example of the normal task from spigot. (See below)

Bukkit.getScheduler().scheduleSyncDelayedTask(this, {
      //Delayed for 20 ticks
}, 20)

Now lets show it with UndefinedAPI. Instead of getting the Bukkit scheduler its a static class that can be used any were inside the plugin. (See below)

Sync / Async

sync { 
    //This task will now be run sync
}
        
async { 
    //This task will now be run async
}

Delayed

Delayed task are just how you think it is. Write down delay and a time and thats it. You are even able to create a delayed async task. (See below)

delay(20) {
    //This task will be run in 20 ticks
}

delay(20, true) {
    //This task will be run in 20 ticks async
}
        
delay(1, TimeUnit.SECONDS, false){
    //This task will be run is 20 ticks sync
}

Repeating

Repeating are very simaller to delayed task. You are also able to choose how many times it get repeated for. (See below)

repeatingTask(1) {
    //This will run every tick
}

repeatingTask(20, 5){
    //This will run every 20 ticks 5 times
}

repeatingTask(1, true){
    //This will run every tick async
}

repeatingTask(20, true, 5){
    //This will run every 20 ticks 5 times async
}

repeatingTask(1, TimeUnit.SECONDS){
    //This will run every second
}

repeatingTask(1, TimeUnit.SECONDS, 5){
    //This will run every second 5 times
}

repeatingTask(1, TimeUnit.SECONDS, true){
    //This will run every second async
}

repeatingTask(1, TimeUnit.SECONDS, 5, true){
    //This will run every second 5 times async
}
Clone this wiki locally