mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-02 16:49:12 +00:00
Update kotlin and coroutines dependencies
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.2.60' apply(false)
|
||||
id 'org.jetbrains.intellij' version '0.3.6' apply(false)
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.40' apply(false)
|
||||
id 'org.jetbrains.intellij' version '0.4.9' apply(false)
|
||||
id 'org.jmailen.kotlinter' version '1.16.0' apply(false)
|
||||
id 'org.sonarqube' version '2.6.2'
|
||||
id "io.gitlab.arturbosch.detekt" version "1.0.0.RC8"
|
||||
|
||||
@@ -12,6 +12,7 @@ dependencies {
|
||||
|
||||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8'
|
||||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-scripting-common'
|
||||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-script-runtime'
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-jdk8', version: kotlinxCoroutinesVersion
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: kotlinxCoroutinesVersion
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import kotlinx.coroutines.experimental.*
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncDistancedAction
|
||||
import org.apollo.game.message.impl.ObjectActionMessage
|
||||
@@ -13,8 +12,8 @@ import org.apollo.net.message.Message
|
||||
val DUMMY_IDS = setOf<Int>(823)
|
||||
|
||||
on { ObjectActionMessage::class }
|
||||
.where { option == 2 && id in DUMMY_IDS }
|
||||
.then { DummyAction.start(this, it, position) }
|
||||
.where { option == 2 && id in DUMMY_IDS }
|
||||
.then { DummyAction.start(this, it, position) }
|
||||
|
||||
class DummyAction(val player: Player, position: Position) : AsyncDistancedAction<Player>(0, true, player, position, DISTANCE) {
|
||||
|
||||
|
||||
@@ -3,14 +3,10 @@ package org.apollo.game.action
|
||||
import java.util.concurrent.CancellationException
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import kotlin.coroutines.experimental.Continuation
|
||||
import kotlin.coroutines.experimental.CoroutineContext
|
||||
import kotlin.coroutines.experimental.EmptyCoroutineContext
|
||||
import kotlin.coroutines.experimental.RestrictsSuspension
|
||||
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
|
||||
import kotlin.coroutines.experimental.intrinsics.createCoroutineUnchecked
|
||||
import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn
|
||||
import kotlinx.coroutines.experimental.suspendCancellableCoroutine
|
||||
import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
|
||||
import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlin.coroutines.*
|
||||
|
||||
typealias ActionPredicate = () -> Boolean
|
||||
typealias ActionBlock = suspend ActionCoroutine.() -> Unit
|
||||
@@ -57,7 +53,7 @@ class ActionCoroutine : Continuation<Unit> {
|
||||
*/
|
||||
fun start(block: ActionBlock): ActionCoroutine {
|
||||
val coroutine = ActionCoroutine()
|
||||
val continuation = block.createCoroutineUnchecked(coroutine, coroutine)
|
||||
val continuation = block.createCoroutine(coroutine, coroutine)
|
||||
|
||||
coroutine.resumeContinuation(continuation)
|
||||
|
||||
@@ -66,8 +62,11 @@ class ActionCoroutine : Continuation<Unit> {
|
||||
}
|
||||
|
||||
override val context: CoroutineContext = EmptyCoroutineContext
|
||||
override fun resume(value: Unit) {}
|
||||
override fun resumeWithException(exception: Throwable) = throw exception
|
||||
override fun resumeWith(result: Result<Unit>) {
|
||||
if (result.isFailure) {
|
||||
throw result.exceptionOrNull()!!
|
||||
}
|
||||
}
|
||||
|
||||
private fun resumeContinuation(continuation: Continuation<Unit>, allowCancellation: Boolean = true) {
|
||||
try {
|
||||
@@ -108,7 +107,7 @@ class ActionCoroutine : Continuation<Unit> {
|
||||
}
|
||||
|
||||
private suspend fun awaitCondition(condition: ActionCoroutineCondition) {
|
||||
return suspendCoroutineOrReturn { cont ->
|
||||
return suspendCoroutineUninterceptedOrReturn { cont ->
|
||||
next.compareAndSet(null, ActionCoroutineStep(condition, cont))
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
@@ -118,7 +117,7 @@ class ActionCoroutine : Continuation<Unit> {
|
||||
* Stop execution of this continuation.
|
||||
*/
|
||||
suspend fun stop(): Nothing {
|
||||
suspendCancellableCoroutine<Unit>(true) { cont ->
|
||||
suspendCancellableCoroutine<Unit> { cont ->
|
||||
next.set(null)
|
||||
cont.cancel()
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.apollo.game.plugin.kotlin
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.script.experimental.annotations.KotlinScript
|
||||
import kotlin.script.experimental.annotations.KotlinScriptFileExtension
|
||||
import org.apollo.game.command.Command
|
||||
import org.apollo.game.command.CommandListener
|
||||
import org.apollo.game.message.handler.MessageHandler
|
||||
@@ -16,8 +15,7 @@ import org.apollo.game.model.event.PlayerEvent
|
||||
import org.apollo.game.plugin.PluginContext
|
||||
import org.apollo.net.message.Message
|
||||
|
||||
@KotlinScript("Apollo Plugin Script")
|
||||
@KotlinScriptFileExtension("plugin.kts")
|
||||
@KotlinScript("Apollo Plugin Script", fileExtension = "plugin.kts")
|
||||
abstract class KotlinPluginScript(private var world: World, val context: PluginContext) {
|
||||
var startListener: (World) -> Unit = { _ -> }
|
||||
var stopListener: (World) -> Unit = { _ -> }
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
kotlin { experimental { coroutines 'enable' } }
|
||||
kotlin {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
ext {
|
||||
kotlinVersion = '1.2.60'
|
||||
kotlinxCoroutinesVersion = '0.24.0'
|
||||
kotlinVersion = '1.3.40'
|
||||
kotlinxCoroutinesVersion = '1.3.0-M2'
|
||||
junitVersion = '4.12'
|
||||
powermockVersion = '1.6.4'
|
||||
bouncycastleVersion = '1.54'
|
||||
@@ -16,5 +16,5 @@ ext {
|
||||
junitJupiterVersion = '5.1.0'
|
||||
mockkVersion = '1.7.15'
|
||||
assertkVersion = '0.9'
|
||||
detektVersion = '1.0.0.RC8'
|
||||
detektVersion = '1.0.0-RC16'
|
||||
}
|
||||
Reference in New Issue
Block a user