io.github.ZeronDev.coroutine.RepeatingScheduler.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ZeronLib Show documentation
Show all versions of ZeronLib Show documentation
Minecraft Plugin Developer
package io.github.ZeronDev.coroutine
import io.github.ZeronDev.LibraryPlugin.plugin
import org.bukkit.Bukkit
import org.bukkit.scheduler.BukkitTask
class RepeatingScheduler {
var scheduler: BukkitTask? = null
companion object {
fun scheduleWith(period: Int, func: ()->Unit) : RepeatingScheduler {
val sch = RepeatingScheduler()
sch.apply {
scheduler = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin!!,
Runnable { func() }, 0L, period.toLong())
}
return sch
}
}
fun stop() {
scheduler?.cancel()
scheduler = null
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy