diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftDecoder.java index ae84e7495c..4051972527 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftDecoder.java @@ -22,6 +22,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.ProtocolUtils; import com.velocitypowered.proxy.protocol.StateRegistry; +import com.velocitypowered.proxy.util.VelocityProperties; import com.velocitypowered.proxy.util.except.QuietRuntimeException; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; @@ -37,6 +38,7 @@ public class MinecraftDecoder extends ChannelInboundHandlerAdapter { private static final QuietRuntimeException DECODE_FAILED = new QuietRuntimeException("A packet did not decode successfully (invalid data). For more " + "information, launch Velocity with -Dvelocity.packet-decode-logging=true to see more."); + private static final boolean DIRECTION_VALIDATION = VelocityProperties.readBoolean("velocity.packet-direction-validation", true); private final ProtocolUtils.Direction direction; private StateRegistry state; @@ -74,7 +76,7 @@ private void tryDecode(ChannelHandlerContext ctx, ByteBuf buf) throws Exception MinecraftPacket packet = this.registry.createPacket(packetId); if (packet == null) { buf.readerIndex(originalReaderIndex); - if (this.direction == ProtocolUtils.Direction.SERVERBOUND && this.state != StateRegistry.PLAY) { + if (DIRECTION_VALIDATION && this.direction == ProtocolUtils.Direction.SERVERBOUND && this.state != StateRegistry.PLAY) { buf.release(); throw this.handleInvalidPacketId(packetId); }