geforkt von Mirrors/Velocity
Use just one byte array in the varint frame decoder.
Dieser Commit ist enthalten in:
Ursprung
f77384d32e
Commit
1e041963f0
@ -6,19 +6,22 @@ import io.netty.buffer.Unpooled;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
import io.netty.handler.codec.CorruptedFrameException;
|
import io.netty.handler.codec.CorruptedFrameException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
||||||
|
|
||||||
|
private final byte[] lenBuf = new byte[3];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
if (!in.isReadable()) {
|
if (!in.isReadable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Arrays.fill(lenBuf, (byte) 0);
|
||||||
int origReaderIndex = in.readerIndex();
|
int origReaderIndex = in.readerIndex();
|
||||||
|
|
||||||
byte[] lenBuf = new byte[3];
|
|
||||||
ByteBuf wrappedBuf = Unpooled.wrappedBuffer(lenBuf);
|
ByteBuf wrappedBuf = Unpooled.wrappedBuffer(lenBuf);
|
||||||
for (int i = 0; i < lenBuf.length; i++) {
|
for (int i = 0; i < lenBuf.length; i++) {
|
||||||
if (!in.isReadable()) {
|
if (!in.isReadable()) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren