diff --git a/src/main/kotlin/com/viaversion/aas/codec/CompressionCodec.kt b/src/main/kotlin/com/viaversion/aas/codec/CompressionCodec.kt index 8f5ce06..c579d7b 100644 --- a/src/main/kotlin/com/viaversion/aas/codec/CompressionCodec.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/CompressionCodec.kt @@ -1,23 +1,23 @@ package com.viaversion.aas.codec +import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf import io.netty.channel.ChannelHandlerContext -import io.netty.handler.codec.DecoderException import io.netty.handler.codec.MessageToMessageCodec import java.util.zip.Deflater import java.util.zip.Inflater class CompressionCodec(val threshold: Int) : MessageToMessageCodec() { // https://github.com/Gerrygames/ClientViaVersion/blob/master/src/main/java/de/gerrygames/the5zig/clientviaversion/netty/CompressionEncoder.java - private val inflater: Inflater = - Inflater()// https://github.com/Gerrygames/ClientViaVersion/blob/master/src/main/java/de/gerrygames/the5zig/clientviaversion/netty/CompressionEncoder.java + private val inflater: Inflater = Inflater() private val deflater: Deflater = Deflater() @Throws(Exception::class) override fun encode(ctx: ChannelHandlerContext, input: ByteBuf, out: MutableList) { val frameLength = input.readableBytes() val outBuf = ctx.alloc().buffer() + outBuf.skipBytes(5) // reserve varint try { if (frameLength < threshold) { outBuf.writeByte(0) @@ -50,19 +50,17 @@ class CompressionCodec(val threshold: Int) : MessageToMessageCodec 2097152) { - throw DecoderException("Badly compressed packet - size of $outLength is larger than protocol maximum of 2097152") + throw StacklessException("Badly compressed packet - size of $outLength is larger than protocol maximum of 2097152") } inflater.setInput(input.nioBuffer()) val output = ctx.alloc().buffer(outLength, outLength) try { output.writerIndex( - output.writerIndex() + inflater.inflate( - output.nioBuffer(output.writerIndex(), output.writableBytes()) - ) + output.writerIndex() + inflater.inflate(output.nioBuffer(output.writerIndex(), output.writableBytes())) ) out.add(output.retain()) } finally { diff --git a/src/main/kotlin/com/viaversion/aas/codec/MinecraftCodec.kt b/src/main/kotlin/com/viaversion/aas/codec/MinecraftCodec.kt index 76f01ef..633703d 100644 --- a/src/main/kotlin/com/viaversion/aas/codec/MinecraftCodec.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/MinecraftCodec.kt @@ -1,8 +1,8 @@ package com.viaversion.aas.codec import com.viaversion.aas.handler.MinecraftHandler -import com.viaversion.aas.packet.Packet -import com.viaversion.aas.packet.PacketRegistry +import com.viaversion.aas.codec.packet.Packet +import com.viaversion.aas.codec.packet.PacketRegistry import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.protocol.packet.Direction import com.viaversion.viaversion.exception.CancelEncoderException diff --git a/src/main/kotlin/com/viaversion/aas/packet/Packet.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/Packet.kt similarity index 85% rename from src/main/kotlin/com/viaversion/aas/packet/Packet.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/Packet.kt index 03363bd..e575e98 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/Packet.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/Packet.kt @@ -1,4 +1,4 @@ -package com.viaversion.aas.packet +package com.viaversion.aas.codec.packet import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/packet/PacketRegistry.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt similarity index 93% rename from src/main/kotlin/com/viaversion/aas/packet/PacketRegistry.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt index 9814124..5117af8 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/PacketRegistry.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt @@ -1,14 +1,14 @@ -package com.viaversion.aas.packet +package com.viaversion.aas.codec.packet import com.google.common.collect.Range -import com.viaversion.aas.packet.handshake.Handshake -import com.viaversion.aas.packet.login.* -import com.viaversion.aas.packet.play.Kick -import com.viaversion.aas.packet.play.PluginMessage -import com.viaversion.aas.packet.status.StatusPing -import com.viaversion.aas.packet.status.StatusPong -import com.viaversion.aas.packet.status.StatusRequest -import com.viaversion.aas.packet.status.StatusResponse +import com.viaversion.aas.codec.packet.handshake.Handshake +import com.viaversion.aas.codec.packet.login.* +import com.viaversion.aas.codec.packet.play.Kick +import com.viaversion.aas.codec.packet.play.PluginMessage +import com.viaversion.aas.codec.packet.status.StatusPing +import com.viaversion.aas.codec.packet.status.StatusPong +import com.viaversion.aas.codec.packet.status.StatusRequest +import com.viaversion.aas.codec.packet.status.StatusResponse import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.protocol.packet.Direction import com.viaversion.viaversion.api.protocol.packet.State diff --git a/src/main/kotlin/com/viaversion/aas/packet/UnknownPacket.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/UnknownPacket.kt similarity index 90% rename from src/main/kotlin/com/viaversion/aas/packet/UnknownPacket.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/UnknownPacket.kt index 27d36df..d2eb292 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/UnknownPacket.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/UnknownPacket.kt @@ -1,4 +1,4 @@ -package com.viaversion.aas.packet +package com.viaversion.aas.codec.packet import com.viaversion.aas.readRemainingBytes import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/packet/handshake/Handshake.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/handshake/Handshake.kt similarity index 90% rename from src/main/kotlin/com/viaversion/aas/packet/handshake/Handshake.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/handshake/Handshake.kt index 65f068c..baabd78 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/handshake/Handshake.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/handshake/Handshake.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.handshake +package com.viaversion.aas.codec.packet.handshake -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.viaversion.api.protocol.packet.State import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/packet/login/CryptoRequest.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoRequest.kt similarity index 94% rename from src/main/kotlin/com/viaversion/aas/packet/login/CryptoRequest.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoRequest.kt index c81f743..6a49132 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/login/CryptoRequest.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoRequest.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.login +package com.viaversion.aas.codec.packet.login -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.readByteArray import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import com.viaversion.viaversion.api.type.Type diff --git a/src/main/kotlin/com/viaversion/aas/packet/login/CryptoResponse.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoResponse.kt similarity index 93% rename from src/main/kotlin/com/viaversion/aas/packet/login/CryptoResponse.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoResponse.kt index d9ddf09..0366ee3 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/login/CryptoResponse.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoResponse.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.login +package com.viaversion.aas.codec.packet.login -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.readByteArray import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import com.viaversion.viaversion.api.type.Type diff --git a/src/main/kotlin/com/viaversion/aas/packet/login/LoginDisconnect.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginDisconnect.kt similarity index 80% rename from src/main/kotlin/com/viaversion/aas/packet/login/LoginDisconnect.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginDisconnect.kt index 3c4f2f4..d758a49 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/login/LoginDisconnect.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginDisconnect.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.login +package com.viaversion.aas.codec.packet.login -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/packet/login/LoginStart.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginStart.kt similarity index 80% rename from src/main/kotlin/com/viaversion/aas/packet/login/LoginStart.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginStart.kt index 3c65a6b..edd3ca4 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/login/LoginStart.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginStart.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.login +package com.viaversion.aas.codec.packet.login -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/packet/login/LoginSuccess.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginSuccess.kt similarity index 93% rename from src/main/kotlin/com/viaversion/aas/packet/login/LoginSuccess.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginSuccess.kt index d47d134..7b408e2 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/login/LoginSuccess.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginSuccess.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.login +package com.viaversion.aas.codec.packet.login -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.parseUndashedId import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import com.viaversion.viaversion.api.type.Type diff --git a/src/main/kotlin/com/viaversion/aas/packet/login/PluginRequest.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/PluginRequest.kt similarity index 88% rename from src/main/kotlin/com/viaversion/aas/packet/login/PluginRequest.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/login/PluginRequest.kt index 8f3dc68..e4413e9 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/login/PluginRequest.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/PluginRequest.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.login +package com.viaversion.aas.codec.packet.login -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.readRemainingBytes import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/packet/login/PluginResponse.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/PluginResponse.kt similarity index 89% rename from src/main/kotlin/com/viaversion/aas/packet/login/PluginResponse.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/login/PluginResponse.kt index 7f04030..9ca3357 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/login/PluginResponse.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/PluginResponse.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.login +package com.viaversion.aas.codec.packet.login -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.readRemainingBytes import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/packet/login/SetCompression.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/SetCompression.kt similarity index 83% rename from src/main/kotlin/com/viaversion/aas/packet/login/SetCompression.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/login/SetCompression.kt index d4a07a6..906b790 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/login/SetCompression.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/SetCompression.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.login +package com.viaversion.aas.codec.packet.login -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf import kotlin.properties.Delegates diff --git a/src/main/kotlin/com/viaversion/aas/packet/play/Kick.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/play/Kick.kt similarity index 79% rename from src/main/kotlin/com/viaversion/aas/packet/play/Kick.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/play/Kick.kt index 80d0306..ed32196 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/play/Kick.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/play/Kick.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.play +package com.viaversion.aas.codec.packet.play -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/packet/play/PluginMessage.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/play/PluginMessage.kt similarity index 95% rename from src/main/kotlin/com/viaversion/aas/packet/play/PluginMessage.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/play/PluginMessage.kt index a396853..518fc41 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/play/PluginMessage.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/play/PluginMessage.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.play +package com.viaversion.aas.codec.packet.play -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.readByteArray import com.viaversion.aas.readRemainingBytes import com.viaversion.viaversion.api.protocol.version.ProtocolVersion diff --git a/src/main/kotlin/com/viaversion/aas/packet/status/StatusPing.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusPing.kt similarity index 79% rename from src/main/kotlin/com/viaversion/aas/packet/status/StatusPing.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusPing.kt index 103e096..a416233 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/status/StatusPing.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusPing.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.status +package com.viaversion.aas.codec.packet.status -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import io.netty.buffer.ByteBuf import kotlin.properties.Delegates diff --git a/src/main/kotlin/com/viaversion/aas/packet/status/StatusPong.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusPong.kt similarity index 84% rename from src/main/kotlin/com/viaversion/aas/packet/status/StatusPong.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusPong.kt index 3a5590d..b26e244 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/status/StatusPong.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusPong.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.status +package com.viaversion.aas.codec.packet.status -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import io.netty.buffer.ByteBuf import kotlin.properties.Delegates diff --git a/src/main/kotlin/com/viaversion/aas/packet/status/StatusRequest.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusRequest.kt similarity index 69% rename from src/main/kotlin/com/viaversion/aas/packet/status/StatusRequest.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusRequest.kt index 7f175c2..dd88505 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/status/StatusRequest.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusRequest.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.status +package com.viaversion.aas.codec.packet.status -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import io.netty.buffer.ByteBuf class StatusRequest : Packet { diff --git a/src/main/kotlin/com/viaversion/aas/packet/status/StatusResponse.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusResponse.kt similarity index 79% rename from src/main/kotlin/com/viaversion/aas/packet/status/StatusResponse.kt rename to src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusResponse.kt index cb521b8..576ac33 100644 --- a/src/main/kotlin/com/viaversion/aas/packet/status/StatusResponse.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/status/StatusResponse.kt @@ -1,6 +1,6 @@ -package com.viaversion.aas.packet.status +package com.viaversion.aas.codec.packet.status -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.viaversion.api.type.Type import io.netty.buffer.ByteBuf diff --git a/src/main/kotlin/com/viaversion/aas/handler/MinecraftHandler.kt b/src/main/kotlin/com/viaversion/aas/handler/MinecraftHandler.kt index 92a7226..23ceb71 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/MinecraftHandler.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/MinecraftHandler.kt @@ -1,7 +1,7 @@ package com.viaversion.aas.handler import com.viaversion.aas.mcLogger -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.setAutoRead import com.viaversion.viaversion.exception.CancelCodecException import io.netty.channel.Channel diff --git a/src/main/kotlin/com/viaversion/aas/handler/Util.kt b/src/main/kotlin/com/viaversion/aas/handler/Util.kt index 3f8e56d..3ce9ad4 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/Util.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/Util.kt @@ -1,7 +1,7 @@ package com.viaversion.aas.handler import com.viaversion.aas.config.VIAaaSConfig -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.send import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import io.netty.channel.ChannelPipeline diff --git a/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetectionState.kt b/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetectionState.kt index a0f79b2..26f298c 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetectionState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetectionState.kt @@ -4,8 +4,8 @@ import com.google.gson.JsonParser import com.viaversion.aas.handler.MinecraftHandler import com.viaversion.aas.handler.state.MinecraftConnectionState import com.viaversion.aas.mcLogger -import com.viaversion.aas.packet.Packet -import com.viaversion.aas.packet.status.StatusResponse +import com.viaversion.aas.codec.packet.Packet +import com.viaversion.aas.codec.packet.status.StatusResponse import com.viaversion.aas.parseProtocol import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.protocol.packet.State diff --git a/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetector.kt b/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetector.kt index ba4ce14..2e1670d 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetector.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetector.kt @@ -10,8 +10,8 @@ import com.viaversion.aas.handler.ConnectionData import com.viaversion.aas.handler.MinecraftHandler import com.viaversion.aas.handler.addSocks5 import com.viaversion.aas.mcLogger -import com.viaversion.aas.packet.handshake.Handshake -import com.viaversion.aas.packet.status.StatusRequest +import com.viaversion.aas.codec.packet.handshake.Handshake +import com.viaversion.aas.codec.packet.status.StatusRequest import com.viaversion.aas.send import com.viaversion.viaversion.api.protocol.packet.State import com.viaversion.viaversion.api.protocol.version.ProtocolVersion diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt index b3f85f4..1b03551 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt @@ -8,8 +8,8 @@ import com.viaversion.aas.VIAaaSAddress import com.viaversion.aas.config.VIAaaSConfig import com.viaversion.aas.handler.MinecraftHandler import com.viaversion.aas.mcLogger -import com.viaversion.aas.packet.Packet -import com.viaversion.aas.packet.handshake.Handshake +import com.viaversion.aas.codec.packet.Packet +import com.viaversion.aas.codec.packet.handshake.Handshake import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.protocol.packet.State import io.netty.channel.ChannelHandlerContext diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt index bdf792a..5c59e90 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt @@ -7,8 +7,8 @@ import com.viaversion.aas.codec.CompressionCodec import com.viaversion.aas.codec.CryptoCodec import com.viaversion.aas.handler.MinecraftHandler import com.viaversion.aas.handler.forward -import com.viaversion.aas.packet.Packet -import com.viaversion.aas.packet.login.* +import com.viaversion.aas.codec.packet.Packet +import com.viaversion.aas.codec.packet.login.* import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.protocol.packet.State import io.netty.channel.Channel diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/MinecraftConnectionState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/MinecraftConnectionState.kt index ee34f25..d442796 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/MinecraftConnectionState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/MinecraftConnectionState.kt @@ -2,7 +2,7 @@ package com.viaversion.aas.handler.state import com.viaversion.aas.handler.MinecraftHandler import com.viaversion.aas.mcLogger -import com.viaversion.aas.packet.Packet +import com.viaversion.aas.codec.packet.Packet import com.viaversion.viaversion.api.protocol.packet.State import io.netty.channel.ChannelHandlerContext diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/PlayState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/PlayState.kt index f6b3b4e..a24e54c 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/PlayState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/PlayState.kt @@ -5,10 +5,10 @@ import com.viaversion.aas.config.VIAaaSConfig import com.viaversion.aas.handler.MinecraftHandler import com.viaversion.aas.handler.forward import com.viaversion.aas.handler.is1_7 -import com.viaversion.aas.packet.Packet -import com.viaversion.aas.packet.UnknownPacket -import com.viaversion.aas.packet.play.Kick -import com.viaversion.aas.packet.play.PluginMessage +import com.viaversion.aas.codec.packet.Packet +import com.viaversion.aas.codec.packet.UnknownPacket +import com.viaversion.aas.codec.packet.play.Kick +import com.viaversion.aas.codec.packet.play.PluginMessage import com.viaversion.aas.parseProtocol import com.viaversion.aas.readRemainingBytes import com.viaversion.aas.util.StacklessException diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/StatusState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/StatusState.kt index 6fc705b..753324b 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/StatusState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/StatusState.kt @@ -6,9 +6,9 @@ import com.google.gson.JsonParser import com.viaversion.aas.config.VIAaaSConfig import com.viaversion.aas.handler.MinecraftHandler import com.viaversion.aas.handler.forward -import com.viaversion.aas.packet.Packet -import com.viaversion.aas.packet.UnknownPacket -import com.viaversion.aas.packet.status.StatusResponse +import com.viaversion.aas.codec.packet.Packet +import com.viaversion.aas.codec.packet.UnknownPacket +import com.viaversion.aas.codec.packet.status.StatusResponse import com.viaversion.aas.parseProtocol import com.viaversion.aas.util.StacklessException import com.viaversion.aas.writeFlushClose diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/Util.kt b/src/main/kotlin/com/viaversion/aas/handler/state/Util.kt index 7e7e2af..597e313 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/Util.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/Util.kt @@ -6,7 +6,7 @@ import com.viaversion.aas.config.VIAaaSConfig import com.viaversion.aas.handler.BackEndInit import com.viaversion.aas.handler.MinecraftHandler import com.viaversion.aas.handler.forward -import com.viaversion.aas.packet.handshake.Handshake +import com.viaversion.aas.codec.packet.handshake.Handshake import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.protocol.packet.State import io.netty.bootstrap.Bootstrap diff --git a/src/main/kotlin/com/viaversion/aas/platform/AspirinViaAPI.kt b/src/main/kotlin/com/viaversion/aas/platform/AspirinViaAPI.kt index 3a516c7..1bd7c05 100644 --- a/src/main/kotlin/com/viaversion/aas/platform/AspirinViaAPI.kt +++ b/src/main/kotlin/com/viaversion/aas/platform/AspirinViaAPI.kt @@ -5,7 +5,6 @@ import io.netty.buffer.ByteBuf import java.util.* object AspirinViaAPI : ViaAPIBase() { - + override fun getPlayerVersion(p0: UUID): Int = super.getPlayerVersion(p0) override fun sendRawPacket(p0: UUID, p1: ByteBuf) = super.sendRawPacket(p0, p1) - override fun getPlayerVersion(p0: UUID?): Int = throw UnsupportedOperationException() } \ No newline at end of file diff --git a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/Protocol1_8To1_7_6.kt b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/Protocol1_8To1_7_6.kt index b4193e1..804e6be 100644 --- a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/Protocol1_8To1_7_6.kt +++ b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/Protocol1_8To1_7_6.kt @@ -7,7 +7,7 @@ import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol // Based on https://github.com/Gerrygames/ClientViaVersion object Protocol1_8To1_7_6 : AbstractSimpleProtocol() { - private val placeable = ArrayList() + private val placeable = hashSetOf() init { placeable.add(6) diff --git a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/chunks/ChunkPacketTransformer.kt b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/chunks/ChunkPacketTransformer.kt index 08e67f0..b32cb67 100644 --- a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/chunks/ChunkPacketTransformer.kt +++ b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/chunks/ChunkPacketTransformer.kt @@ -5,9 +5,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper import com.viaversion.viaversion.api.type.Type import com.viaversion.viaversion.api.type.types.CustomByteType import com.viaversion.viaversion.protocol.packet.PacketWrapperImpl -import java.io.IOException import java.util.stream.IntStream -import java.util.zip.DataFormatException import java.util.zip.Inflater import kotlin.streams.toList @@ -72,8 +70,6 @@ object ChunkPacketTransformer { inflater.setInput(buildBuffer, 0, compressedSize) try { inflater.inflate(data) - } catch (ex: DataFormatException) { - throw IOException("Bad compressed data format") } finally { inflater.end() } @@ -138,7 +134,7 @@ object ChunkPacketTransformer { val y = encodedPos.and(0xFF) val z = encodedPos.ushr(8).and(0xF) BlockChangeRecord1_8(x, y, z, blocks[it].toInt()) - } - .toList().toTypedArray()) + }.toList().toTypedArray() + ) } } \ No newline at end of file