mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-01-09 19:48:37 +01:00
try to generate less exceptions
This commit is contained in:
parent
4de94027d1
commit
a3377bd69a
@ -7,10 +7,11 @@ import io.netty.buffer.ByteBuf
|
||||
import io.netty.buffer.ByteBufAllocator
|
||||
import io.netty.channel.ChannelHandlerContext
|
||||
import io.netty.handler.codec.MessageToMessageCodec
|
||||
import us.myles.ViaVersion.exception.CancelEncoderException
|
||||
|
||||
class MinecraftCodec : MessageToMessageCodec<ByteBuf, Packet>() {
|
||||
override fun encode(ctx: ChannelHandlerContext, msg: Packet, out: MutableList<Any>) {
|
||||
if (!ctx.channel().isActive) return
|
||||
if (!ctx.channel().isActive) throw CancelEncoderException.CACHED
|
||||
val buf = ByteBufAllocator.DEFAULT.buffer()
|
||||
try {
|
||||
val handler = ctx.pipeline().get(MinecraftHandler::class.java)
|
||||
|
@ -25,6 +25,7 @@ class ViaCodec(val info: UserConnection) : MessageToMessageCodec<ByteBuf, ByteBu
|
||||
}
|
||||
|
||||
override fun encode(ctx: ChannelHandlerContext, bytebuf: ByteBuf, out: MutableList<Any>) {
|
||||
if (!ctx.channel().isActive) throw CancelEncoderException.CACHED
|
||||
if (!info.checkOutgoingPacket()) throw CancelEncoderException.generate(null)
|
||||
if (!info.shouldTransformPacket()) {
|
||||
out.add(bytebuf.retain())
|
||||
|
Loading…
Reference in New Issue
Block a user