fix Packet
This commit is contained in:
@@ -14,8 +14,9 @@ dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
implementation(project(":api"))
|
||||
implementation(project(":common"))
|
||||
implementation("io.netty:netty-all:4.1.90.Final")
|
||||
@Suppress("VulnerableLibrariesLocal")
|
||||
compileOnly("io.github.waterfallmc:waterfall-api:1.19-R0.1-SNAPSHOT")
|
||||
implementation("io.github.waterfallmc:waterfall-api:1.19-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
|
||||
@@ -2,6 +2,8 @@ package cc.maxmc.msm.child
|
||||
|
||||
import cc.maxmc.msm.child.command.Send
|
||||
import cc.maxmc.msm.child.netty.NetClient
|
||||
import cc.maxmc.msm.child.settings.Settings
|
||||
import cc.maxmc.msm.common.network.netty.NetworkRegistry
|
||||
import net.md_5.bungee.api.ProxyServer
|
||||
import net.md_5.bungee.api.plugin.Plugin
|
||||
|
||||
@@ -12,7 +14,8 @@ class MultiServerMan : Plugin() {
|
||||
|
||||
override fun onEnable() {
|
||||
ProxyServer.getInstance().pluginManager.registerCommand(this, Send)
|
||||
NetClient.start()
|
||||
NetworkRegistry
|
||||
NetClient.start(Settings.Parent.address, Settings.Parent.port)
|
||||
}
|
||||
|
||||
override fun onDisable() {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package cc.maxmc.msm.child.netty
|
||||
|
||||
import cc.maxmc.msm.child.settings.Settings
|
||||
import cc.maxmc.msm.common.network.BungeePacket
|
||||
import cc.maxmc.msm.common.utils.log
|
||||
import cc.maxmc.msm.common.network.netty.NetworkRegistry
|
||||
import cc.maxmc.msm.common.utils.pipelineInit
|
||||
import io.netty.bootstrap.Bootstrap
|
||||
import io.netty.channel.Channel
|
||||
@@ -16,18 +15,17 @@ object NetClient {
|
||||
lateinit var channel: Channel
|
||||
private set
|
||||
|
||||
fun start() {
|
||||
val parent = Settings.Parent
|
||||
Bootstrap()
|
||||
fun start(address: String, port: Int) {
|
||||
val future = Bootstrap()
|
||||
.channel(NioSocketChannel::class.java)
|
||||
.group(loop)
|
||||
.handler(pipelineInit())
|
||||
.handler(pipelineInit(NetworkRegistry.PacketDirection.CHILD_BOUND))
|
||||
.option(ChannelOption.TCP_NODELAY, true)
|
||||
.remoteAddress(parent.address, parent.port)
|
||||
.remoteAddress(address, port)
|
||||
.connect().addListener(ChannelFutureListener {
|
||||
channel = it.channel()
|
||||
log("§a| §7成功连接到集群的主节点. (${it.channel().remoteAddress()})")
|
||||
println("§a| §7成功连接到集群的主节点. (${it.channel().remoteAddress()})")
|
||||
})
|
||||
channel = future.channel()
|
||||
}
|
||||
|
||||
fun sendPacket(packet: BungeePacket) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
name: MultiServerMan-Parent
|
||||
name: MultiServerMan-Child
|
||||
main: cc.maxmc.msm.child.MultiServerMan
|
||||
author: TONY_All
|
||||
Reference in New Issue
Block a user