mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-06 06:51:31 +00:00
Initial work on multi-server bridge from a while back.
This commit is contained in:
@ -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"))
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
@ -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()
|
||||
}
|
||||
}
|
@ -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",
|
||||
)
|
5
foundation-bifrost/src/main/resources/bifrost-multi.yaml
Normal file
5
foundation-bifrost/src/main/resources/bifrost-multi.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
# Configuration for the Bifrost multi-server chat bridge.
|
||||
|
||||
messageQueue:
|
||||
host: localhost
|
||||
|
Reference in New Issue
Block a user