mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-28 13:05:16 +01:00
closes #23
This commit is contained in:
parent
6a6bbe28d3
commit
b5e00e1413
@ -56,7 +56,7 @@ class CloudMinecraftHandler(val user: UserConnection,
|
|||||||
var address: SocketAddress? = null
|
var address: SocketAddress? = null
|
||||||
|
|
||||||
override fun channelRead0(ctx: ChannelHandlerContext, msg: ByteBuf) {
|
override fun channelRead0(ctx: ChannelHandlerContext, msg: ByteBuf) {
|
||||||
if (ctx.channel().isActive && !user.isPendingDisconnect) {
|
if (ctx.channel().isActive && !user.isPendingDisconnect && msg.isReadable) {
|
||||||
data!!.state.handleMessage(this, ctx, msg)
|
data!!.state.handleMessage(this, ctx, msg)
|
||||||
if (msg.isReadable) throw IllegalStateException("Remaining bytes!!!")
|
if (msg.isReadable) throw IllegalStateException("Remaining bytes!!!")
|
||||||
//other?.write(msg.retain())
|
//other?.write(msg.retain())
|
||||||
@ -369,10 +369,7 @@ object LoginState : MinecraftConnectionState {
|
|||||||
object StatusState : MinecraftConnectionState {
|
object StatusState : MinecraftConnectionState {
|
||||||
override fun handleMessage(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, msg: ByteBuf) {
|
override fun handleMessage(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, msg: ByteBuf) {
|
||||||
val i = msg.readerIndex()
|
val i = msg.readerIndex()
|
||||||
when (Type.VAR_INT.readPrimitive(msg)) {
|
if (Type.VAR_INT.readPrimitive(msg) !in 0..1) throw IllegalArgumentException("Invalid packet id!")
|
||||||
0, 1 -> {}
|
|
||||||
else -> throw IllegalArgumentException("Invalid packet id!")
|
|
||||||
}
|
|
||||||
msg.readerIndex(i)
|
msg.readerIndex(i)
|
||||||
handler.other!!.write(msg.retain())
|
handler.other!!.write(msg.retain())
|
||||||
}
|
}
|
||||||
@ -395,6 +392,9 @@ object StatusState : MinecraftConnectionState {
|
|||||||
|
|
||||||
object PlayState : MinecraftConnectionState {
|
object PlayState : MinecraftConnectionState {
|
||||||
override fun handleMessage(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, msg: ByteBuf) {
|
override fun handleMessage(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, msg: ByteBuf) {
|
||||||
|
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.retain())
|
handler.other!!.write(msg.retain())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user