diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0c03e83..ece8f50 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `kotlin-dsl` - kotlin("plugin.serialization") version "1.5.31" + kotlin("plugin.serialization") version "1.6.21" } repositories { @@ -8,10 +8,10 @@ repositories { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") - implementation("org.jetbrains.kotlin:kotlin-serialization:1.6.10") - implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.1") - implementation("com.google.code.gson:gson:2.8.9") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21") + implementation("org.jetbrains.kotlin:kotlin-serialization:1.6.21") + implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2") + implementation("com.google.code.gson:gson:2.9.0") implementation("org.bouncycastle:bcprov-jdk15on:1.70") } diff --git a/foundation-bifrost/build.gradle.kts b/foundation-bifrost/build.gradle.kts index 67598be..011101e 100644 --- a/foundation-bifrost/build.gradle.kts +++ b/foundation-bifrost/build.gradle.kts @@ -2,6 +2,7 @@ dependencies { implementation("net.dv8tion:JDA:5.0.0-alpha.2") { exclude(module = "opus-java") } + implementation("com.rabbitmq:amqp-client:5.14.2") compileOnly(project(":foundation-core")) } diff --git a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/EventHandler.kt b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/EventHandler.kt new file mode 100644 index 0000000..0d3ec3f --- /dev/null +++ b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/EventHandler.kt @@ -0,0 +1,11 @@ +package cloud.kubelet.foundation.bifrost + +import io.papermc.paper.event.player.AsyncChatEvent +import org.bukkit.event.player.PlayerJoinEvent +import org.bukkit.event.player.PlayerQuitEvent + +interface EventHandler { + fun onPlayerJoin(e: PlayerJoinEvent) + fun onPlayerQuit(e: PlayerQuitEvent) + fun onChat(e: AsyncChatEvent) +} diff --git a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/MultiServerEventHandler.kt b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/MultiServerEventHandler.kt new file mode 100644 index 0000000..b618f52 --- /dev/null +++ b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/MultiServerEventHandler.kt @@ -0,0 +1,26 @@ +package cloud.kubelet.foundation.bifrost + +import cloud.kubelet.foundation.bifrost.model.BifrostMessageQueueConfig +import cloud.kubelet.foundation.bifrost.model.BifrostMultiConfig +import com.rabbitmq.client.Connection +import com.rabbitmq.client.ConnectionFactory +import io.papermc.paper.event.player.AsyncChatEvent + +class MultiServerEventHandler(config: BifrostMultiConfig) : EventHandler { + private val bus = buildConnection(config.messageQueue) + private val channel = bus.createChannel() + + init { + channel.queueDeclare(config.messageQueue.queueName, false, false, false, emptyMap()) + } + + override fun onChat(e: AsyncChatEvent) { + } + + private companion object { + fun buildConnection(config: BifrostMessageQueueConfig): Connection = ConnectionFactory().apply { + host = config.host + port = config.port + }.newConnection() + } +} diff --git a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/model/BifrostMultiConfig.kt b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/model/BifrostMultiConfig.kt new file mode 100644 index 0000000..6e7e401 --- /dev/null +++ b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/model/BifrostMultiConfig.kt @@ -0,0 +1,19 @@ +package cloud.kubelet.foundation.bifrost.model + +import kotlinx.serialization.Serializable + +@Serializable +data class BifrostMultiConfig( + val messageQueue: BifrostMessageQueueConfig, +) + +@Serializable +data class BifrostMessageQueueConfig( + val host: String = "localhost", + val port: Int = 5672, + + /** + * Name of the RabbitMQ queue + */ + val queueName: String = "bifrost", +) diff --git a/foundation-bifrost/src/main/resources/bifrost-multi.yaml b/foundation-bifrost/src/main/resources/bifrost-multi.yaml new file mode 100644 index 0000000..a7becaf --- /dev/null +++ b/foundation-bifrost/src/main/resources/bifrost-multi.yaml @@ -0,0 +1,5 @@ +# Configuration for the Bifrost multi-server chat bridge. + +messageQueue: + host: localhost + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e589..aa991fc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists