Changed runTask to bukkitRun
Changed the runTask method to bukkitRun and added documentation
This commit is contained in:
@@ -40,7 +40,7 @@ abstract class ChainedRunnablePart<T, R>(
|
|||||||
)
|
)
|
||||||
|
|
||||||
protected fun start(data: T) {
|
protected fun start(data: T) {
|
||||||
runTask(sync) {
|
bukkitRun(sync) {
|
||||||
val result = invoke(data)
|
val result = invoke(data)
|
||||||
next?.start(result)
|
next?.start(result)
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ abstract class ChainedRunnablePart<T, R>(
|
|||||||
exceptionSync: Boolean,
|
exceptionSync: Boolean,
|
||||||
exceptionHandler: ((E) -> Unit)?,
|
exceptionHandler: ((E) -> Unit)?,
|
||||||
) {
|
) {
|
||||||
runTask(sync) {
|
bukkitRun(sync) {
|
||||||
val result = try {
|
val result = try {
|
||||||
invoke(data)
|
invoke(data)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -61,11 +61,11 @@ abstract class ChainedRunnablePart<T, R>(
|
|||||||
if (sync == exceptionSync) {
|
if (sync == exceptionSync) {
|
||||||
exceptionHandler?.invoke(e as E)
|
exceptionHandler?.invoke(e as E)
|
||||||
} else if (exceptionHandler != null) {
|
} else if (exceptionHandler != null) {
|
||||||
runTask(exceptionSync) {
|
bukkitRun(exceptionSync) {
|
||||||
exceptionHandler.invoke(e as E)
|
exceptionHandler.invoke(e as E)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return@runTask
|
return@bukkitRun
|
||||||
} else throw e
|
} else throw e
|
||||||
}
|
}
|
||||||
next?.startCatching(result, exceptionClass, exceptionSync, exceptionHandler)
|
next?.startCatching(result, exceptionClass, exceptionSync, exceptionHandler)
|
||||||
|
@@ -104,7 +104,11 @@ fun task(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun runTask(sync: Boolean, runnable: () -> Unit) {
|
/**
|
||||||
|
* Executes the given [runnable] either
|
||||||
|
* sync or async (specified by the [sync] parameter).
|
||||||
|
*/
|
||||||
|
fun bukkitRun(sync: Boolean, runnable: () -> Unit) {
|
||||||
if (sync) {
|
if (sync) {
|
||||||
sync(runnable)
|
sync(runnable)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user