diff --git a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java index 267e0f7e3..cf0b03385 100644 --- a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java +++ b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java @@ -92,20 +92,21 @@ public class ProtocolPipeline extends Protocol { } else { type = PacketType.findNewPacket(state, direction, originalID); } + if (type != null) { + // Filter :) This would be not hard coded too, sorry :( + if (type == PacketType.PLAY_CHUNK_DATA) return; + if (type == PacketType.PLAY_TIME_UPDATE) return; + if (type == PacketType.PLAY_KEEP_ALIVE) return; + if (type == PacketType.PLAY_KEEP_ALIVE_REQUEST) return; + if (type == PacketType.PLAY_ENTITY_LOOK_MOVE) return; + if (type == PacketType.PLAY_ENTITY_LOOK) return; + if (type == PacketType.PLAY_ENTITY_RELATIVE_MOVE) return; + if (type == PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST) return; + if (type == PacketType.PLAY_PLAYER_LOOK_REQUEST) return; + if (type == PacketType.PLAY_PLAYER_POSITION_REQUEST) return; - // Filter :) This would be not hard coded too, sorry :( - if (type == PacketType.PLAY_CHUNK_DATA) return; - if (type == PacketType.PLAY_TIME_UPDATE) return; - if (type == PacketType.PLAY_KEEP_ALIVE) return; - if (type == PacketType.PLAY_KEEP_ALIVE_REQUEST) return; - if (type == PacketType.PLAY_ENTITY_LOOK_MOVE) return; - if (type == PacketType.PLAY_ENTITY_LOOK) return; - if (type == PacketType.PLAY_ENTITY_RELATIVE_MOVE) return; - if (type == PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST) return; - if (type == PacketType.PLAY_PLAYER_LOOK_REQUEST) return; - if (type == PacketType.PLAY_PLAYER_POSITION_REQUEST) return; - - packet = type.name(); + packet = type.name(); + } } String name = packet + "[" + userConnection.get(ProtocolInfo.class).getProtocolVersion() + "]"; ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance(); diff --git a/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java b/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java index a830ef8ec..eab18604d 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java +++ b/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java @@ -19,6 +19,7 @@ import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.State; import java.util.List; @@ -170,4 +171,15 @@ public class BaseProtocol extends Protocol { } }, plugin); } + + @Override + public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception { + super.transform(direction, state, packetWrapper); + if (direction == Direction.INCOMING && state == State.HANDSHAKE) { + // Disable if it isn't a handshake packet. + if (packetWrapper.getId() > 0) { + packetWrapper.user().setActive(false); + } + } + } }