diff --git a/src/main/kotlin/net/axay/kspigot/runnables/KSpigotRunnables.kt b/src/main/kotlin/net/axay/kspigot/runnables/KSpigotRunnables.kt index ddd87bd0..f98bbee8 100644 --- a/src/main/kotlin/net/axay/kspigot/runnables/KSpigotRunnables.kt +++ b/src/main/kotlin/net/axay/kspigot/runnables/KSpigotRunnables.kt @@ -46,6 +46,8 @@ abstract class KSpigotRunnable( * even if the server shuts down or the runnable ends prematurely * @param endCallback code that should always be executed when the runnable ends * @param runnable the runnable which should be executed each repetition + * + * @return the [KSpigotRunnable] */ fun task( sync: Boolean = true, @@ -55,9 +57,9 @@ fun task( safe: Boolean = false, endCallback: (() -> Unit)? = null, runnable: ((KSpigotRunnable) -> Unit)? = null -) { +): KSpigotRunnable? { - if (howOften != null && howOften == 0L) return + if (howOften != null && howOften == 0L) return null val bukkitRunnable = object : KSpigotRunnable() { @@ -103,6 +105,8 @@ fun task( if (sync) bukkitRunnable.runTaskLater(KSpigotMainInstance, delay) else bukkitRunnable.runTaskLaterAsynchronously(KSpigotMainInstance, delay) + return bukkitRunnable + } /**