mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-01-23 21:52:35 +01:00
fixed last commit
This commit is contained in:
parent
0c5ef88567
commit
9e60fcb2e3
@ -65,7 +65,6 @@ class CloudMinecraftHandler(
|
||||
if (ctx.channel().isActive && msg.isReadable) {
|
||||
data.state.handleMessage(this, ctx, msg)
|
||||
if (msg.isReadable) throw IllegalStateException("Remaining bytes!!!")
|
||||
//other?.write(msg.retain())
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,7 +371,7 @@ object StatusState : MinecraftConnectionState {
|
||||
val i = msg.readerIndex()
|
||||
if (Type.VAR_INT.readPrimitive(msg) !in 0..1) throw IllegalArgumentException("Invalid packet id!")
|
||||
msg.readerIndex(i)
|
||||
handler.other!!.write(msg.retainedSlice(), ctx.voidPromise())
|
||||
forward(handler, msg.retainedSlice())
|
||||
msg.clear()
|
||||
}
|
||||
|
||||
@ -399,7 +398,7 @@ object PlayState : MinecraftConnectionState {
|
||||
val i = msg.readerIndex()
|
||||
if (Type.VAR_INT.readPrimitive(msg) !in 0..127) throw IllegalArgumentException("Invalid packet id!")
|
||||
msg.readerIndex(i)
|
||||
handler.other!!.write(msg.retainedSlice(), ctx.voidPromise())
|
||||
forward(handler, msg.retainedSlice())
|
||||
msg.clear()
|
||||
}
|
||||
|
||||
@ -447,20 +446,25 @@ fun generateServerHash(serverId: String, sharedSecret: ByteArray?, key: PublicKe
|
||||
return twosComplementHexdigest(digest.digest())
|
||||
}
|
||||
|
||||
private fun forward(handler: CloudMinecraftHandler, packet: Packet, channelPromise: ChannelPromise, flush: Boolean = false) {
|
||||
private fun forward(handler: CloudMinecraftHandler, packet: Packet, flush: Boolean = false) {
|
||||
val msg = ByteBufAllocator.DEFAULT.buffer()
|
||||
try {
|
||||
PacketRegistry.encode(packet, msg, ProtocolVersion.getProtocol(handler.data.frontVer!!))
|
||||
if (flush) {
|
||||
handler.other!!.writeAndFlush(msg.retain(), channelPromise)
|
||||
} else {
|
||||
handler.other!!.write(msg.retain(), channelPromise)
|
||||
}
|
||||
forward(handler, msg.retain(), flush)
|
||||
} finally {
|
||||
msg.release()
|
||||
}
|
||||
}
|
||||
|
||||
private fun forward(handler: CloudMinecraftHandler, byteBuf: ByteBuf, flush: Boolean = false) {
|
||||
val ch = handler.other!!
|
||||
if (flush) {
|
||||
ch.writeAndFlush(byteBuf, ch.voidPromise())
|
||||
} else {
|
||||
ch.write(byteBuf, ch.voidPromise())
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolveSrv(address: String, port: Int): Pair<String, Int> {
|
||||
if (port == 25565) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user