Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down