From 02619c6132fb8c9675158ae9a91519c22b3a344b Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 1 Nov 2013 17:52:14 +1100 Subject: [PATCH] Close #689 - fix serverinfo.ping --- .../java/net/md_5/bungee/connection/PingHandler.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java index fbc8c7d35..5ca29c1d8 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java @@ -7,6 +7,9 @@ import net.md_5.bungee.api.ServerPing; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.netty.ChannelWrapper; import net.md_5.bungee.netty.PacketHandler; +import net.md_5.bungee.netty.PipelineUtils; +import net.md_5.bungee.protocol.MinecraftDecoder; +import net.md_5.bungee.protocol.MinecraftEncoder; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.StatusRequest; @@ -24,8 +27,14 @@ public class PingHandler extends PacketHandler public void connected(ChannelWrapper channel) throws Exception { this.channel = channel; + MinecraftEncoder encoder = new MinecraftEncoder( Protocol.HANDSHAKE, false ); + + channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER, new MinecraftDecoder( Protocol.STATUS, false ) ); + channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, encoder ); channel.write( new Handshake( Protocol.PROTOCOL_VERSION, target.getAddress().getHostString(), target.getAddress().getPort(), 1 ) ); + + encoder.setProtocol( Protocol.STATUS ); channel.write( new StatusRequest() ); }