From e65b3c724cd86faa24d3ca3ece804f7e8edc2c67 Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Sun, 10 Jan 2021 22:07:15 +0100 Subject: [PATCH] Update KSpigotRunnables.kt --- .../kotlin/net/axay/kspigot/runnables/KSpigotRunnables.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 + } /**