Make MinecraftDecoder a MessageToMessageDecoder
This commit is contained in:
parent
93959cab4b
commit
ddfd76ebda
@ -2,13 +2,13 @@ package net.md_5.bungee.protocol;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MinecraftDecoder extends ByteToMessageDecoder
|
public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
|
@ -29,6 +29,10 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|||||||
if ( buf[i] >= 0 )
|
if ( buf[i] >= 0 )
|
||||||
{
|
{
|
||||||
int length = DefinedPacket.readVarInt( Unpooled.wrappedBuffer( buf ) );
|
int length = DefinedPacket.readVarInt( Unpooled.wrappedBuffer( buf ) );
|
||||||
|
if ( length == 0 )
|
||||||
|
{
|
||||||
|
throw new CorruptedFrameException( "Empty Packet!" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( in.readableBytes() < length )
|
if ( in.readableBytes() < length )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user