Properly kick older clients
This commit is contained in:
parent
80caa2b669
commit
8c367d86e7
@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user