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
|
||||
|
||||
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)
|
||||
if (msg.isReadable) throw IllegalStateException("Remaining bytes!!!")
|
||||
//other?.write(msg.retain())
|
||||
@ -369,10 +369,7 @@ object LoginState : MinecraftConnectionState {
|
||||
object StatusState : MinecraftConnectionState {
|
||||
override fun handleMessage(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, msg: ByteBuf) {
|
||||
val i = msg.readerIndex()
|
||||
when (Type.VAR_INT.readPrimitive(msg)) {
|
||||
0, 1 -> {}
|
||||
else -> throw IllegalArgumentException("Invalid packet id!")
|
||||
}
|
||||
if (Type.VAR_INT.readPrimitive(msg) !in 0..1) throw IllegalArgumentException("Invalid packet id!")
|
||||
msg.readerIndex(i)
|
||||
handler.other!!.write(msg.retain())
|
||||
}
|
||||
@ -395,6 +392,9 @@ object StatusState : MinecraftConnectionState {
|
||||
|
||||
object PlayState : MinecraftConnectionState {
|
||||
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())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user