1.6.4 ping support
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URLEncoder;
|
||||
@@ -44,8 +46,8 @@ import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
@@ -119,6 +121,20 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(LegacyPing ping) throws Exception
|
||||
{
|
||||
String kickMessage = ChatColor.DARK_BLUE
|
||||
+ "\00" + bungee.getProtocolVersion()
|
||||
+ "\00" + bungee.getGameVersion()
|
||||
+ "\00" + listener.getMotd()
|
||||
+ "\00" + bungee.getOnlineCount()
|
||||
+ "\00" + listener.getMaxPlayers();
|
||||
|
||||
ch.getHandle().writeAndFlush( kickMessage );
|
||||
ch.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(StatusRequest statusRequest) throws Exception
|
||||
{
|
||||
@@ -231,7 +247,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
// TODO: Nuuuu Mojang why u do this
|
||||
// unsafe().sendPacket( PacketConstants.I_AM_BUNGEE );
|
||||
// unsafe().sendPacket( PacketConstants.FORGE_MOD_REQUEST );
|
||||
|
||||
unsafe().sendPacket( request = EncryptionUtil.encryptRequest( this.onlineMode ) );
|
||||
thisState = State.ENCRYPT;
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@ import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.protocol.KickStringWriter;
|
||||
import net.md_5.bungee.protocol.LegacyDecoder;
|
||||
import net.md_5.bungee.protocol.MinecraftDecoder;
|
||||
import net.md_5.bungee.protocol.MinecraftEncoder;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
@@ -39,8 +41,10 @@ public class PipelineUtils
|
||||
}
|
||||
|
||||
BASE.initChannel( ch );
|
||||
ch.pipeline().addBefore( FRAME_DECODER, LEGACY_DECODER, new LegacyDecoder() );
|
||||
ch.pipeline().addAfter( FRAME_DECODER, PACKET_DECODER, new MinecraftDecoder( Protocol.HANDSHAKE, true ) );
|
||||
ch.pipeline().addAfter( FRAME_PREPENDER, PACKET_ENCODER, new MinecraftEncoder( Protocol.HANDSHAKE, true ) );
|
||||
ch.pipeline().addBefore( FRAME_PREPENDER, LEGACY_KICKER, new KickStringWriter() );
|
||||
ch.pipeline().get( HandlerBoss.class ).setHandler( new InitialHandler( ProxyServer.getInstance(), ch.attr( LISTENER ).get() ) );
|
||||
}
|
||||
};
|
||||
@@ -54,6 +58,8 @@ public class PipelineUtils
|
||||
public static String DECRYPT_HANDLER = "decrypt";
|
||||
public static String FRAME_DECODER = "frame-decoder";
|
||||
public static String FRAME_PREPENDER = "frame-prepender";
|
||||
public static String LEGACY_DECODER = "legacy-decoder";
|
||||
public static String LEGACY_KICKER = "legacy-kick";
|
||||
|
||||
public final static class Base extends ChannelInitializer<Channel>
|
||||
{
|
||||
|
Reference in New Issue
Block a user