diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java index 08b12630..2203489d 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java @@ -17,6 +17,7 @@ import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.EncryptionResponse; +import net.md_5.bungee.protocol.packet.LegacyHandshake; import net.md_5.bungee.protocol.packet.LegacyPing; import net.md_5.bungee.protocol.packet.LoginRequest; import net.md_5.bungee.protocol.packet.LoginSuccess; @@ -123,4 +124,8 @@ public abstract class AbstractPacketHandler public void handle(LoginSuccess loginSuccess) throws Exception { } + + public void handle(LegacyHandshake legacyHandshake) throws Exception + { + } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/LegacyDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/LegacyDecoder.java index 7cc06d9b..ee4a3350 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/LegacyDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/LegacyDecoder.java @@ -5,6 +5,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; import java.util.List; +import net.md_5.bungee.protocol.packet.LegacyHandshake; import net.md_5.bungee.protocol.packet.LegacyPing; public class LegacyDecoder extends ByteToMessageDecoder @@ -26,6 +27,10 @@ public class LegacyDecoder extends ByteToMessageDecoder { out.add( new PacketWrapper( new LegacyPing(), Unpooled.EMPTY_BUFFER ) ); } + if ( b1 == 0x02 && b2 >= 60 && b2 <= 78 ) + { + out.add( new PacketWrapper( new LegacyHandshake(), Unpooled.EMPTY_BUFFER ) ); + } ctx.pipeline().remove( this ); } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LegacyHandshake.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LegacyHandshake.java new file mode 100644 index 00000000..50d73816 --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LegacyHandshake.java @@ -0,0 +1,33 @@ +package net.md_5.bungee.protocol.packet; + +import io.netty.buffer.ByteBuf; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import net.md_5.bungee.protocol.AbstractPacketHandler; +import net.md_5.bungee.protocol.DefinedPacket; + +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class LegacyHandshake extends DefinedPacket +{ + + @Override + public void read(ByteBuf buf) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + @Override + public void write(ByteBuf buf) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + @Override + public void handle(AbstractPacketHandler handler) throws Exception + { + handler.handle( this ); + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 26b6e6d4..4209d7ca 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -45,6 +45,7 @@ import net.md_5.bungee.api.AbstractReconnectHandler; import net.md_5.bungee.api.event.PlayerHandshakeEvent; import net.md_5.bungee.api.event.PreLoginEvent; import net.md_5.bungee.protocol.Protocol; +import net.md_5.bungee.protocol.packet.LegacyHandshake; import net.md_5.bungee.protocol.packet.LegacyPing; import net.md_5.bungee.protocol.packet.LoginRequest; import net.md_5.bungee.protocol.packet.LoginSuccess; @@ -119,6 +120,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection } } + @Override + public void handle(LegacyHandshake legacyHandshake) throws Exception + { + ch.getHandle().writeAndFlush( bungee.getTranslation( "outdated_client" ) ); + ch.close(); + } + @Override public void handle(LegacyPing ping) throws Exception {