Pass the protocol version through when using ping pass through
This commit is contained in:
parent
cd518690fd
commit
86ef046544
@ -19,6 +19,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.Synchronized;
|
import lombok.Synchronized;
|
||||||
import net.md_5.bungee.api.Callback;
|
import net.md_5.bungee.api.Callback;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.ServerPing;
|
import net.md_5.bungee.api.ServerPing;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -105,6 +106,11 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ping(final Callback<ServerPing> callback)
|
public void ping(final Callback<ServerPing> callback)
|
||||||
|
{
|
||||||
|
ping( callback, ProxyServer.getInstance().getProtocolVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ping(final Callback<ServerPing> callback, final int protocolVersion)
|
||||||
{
|
{
|
||||||
Preconditions.checkNotNull( callback, "callback" );
|
Preconditions.checkNotNull( callback, "callback" );
|
||||||
|
|
||||||
@ -115,7 +121,7 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
{
|
{
|
||||||
if ( future.isSuccess() )
|
if ( future.isSuccess() )
|
||||||
{
|
{
|
||||||
future.channel().pipeline().get( HandlerBoss.class ).setHandler( new PingHandler( BungeeServerInfo.this, callback ) );
|
future.channel().pipeline().get( HandlerBoss.class ).setHandler( new PingHandler( BungeeServerInfo.this, callback, protocolVersion ) );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
callback.done( null, future.cause() );
|
callback.done( null, future.cause() );
|
||||||
|
@ -167,7 +167,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
|
|
||||||
if ( forced != null && listener.isPingPassthrough() )
|
if ( forced != null && listener.isPingPassthrough() )
|
||||||
{
|
{
|
||||||
forced.ping( pingBack );
|
((BungeeServerInfo) forced).ping( pingBack, handshake.getProtocolVersion() );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
int protocol = ( Protocol.supportedVersions.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : -1;
|
int protocol = ( Protocol.supportedVersions.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : -1;
|
||||||
|
@ -22,18 +22,19 @@ public class PingHandler extends PacketHandler
|
|||||||
|
|
||||||
private final ServerInfo target;
|
private final ServerInfo target;
|
||||||
private final Callback<ServerPing> callback;
|
private final Callback<ServerPing> callback;
|
||||||
|
private final int protocol;
|
||||||
private ChannelWrapper channel;
|
private ChannelWrapper channel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connected(ChannelWrapper channel) throws Exception
|
public void connected(ChannelWrapper channel) throws Exception
|
||||||
{
|
{
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
MinecraftEncoder encoder = new MinecraftEncoder( Protocol.HANDSHAKE, false, ProxyServer.getInstance().getProtocolVersion() );
|
MinecraftEncoder encoder = new MinecraftEncoder( Protocol.HANDSHAKE, false, protocol );
|
||||||
|
|
||||||
channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER, new MinecraftDecoder( Protocol.STATUS, false, ProxyServer.getInstance().getProtocolVersion() ) );
|
channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER, new MinecraftDecoder( Protocol.STATUS, false, ProxyServer.getInstance().getProtocolVersion() ) );
|
||||||
channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, encoder );
|
channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, encoder );
|
||||||
|
|
||||||
channel.write( new Handshake( ProxyServer.getInstance().getProtocolVersion(), target.getAddress().getHostString(), target.getAddress().getPort(), 1 ) );
|
channel.write( new Handshake( protocol, target.getAddress().getHostString(), target.getAddress().getPort(), 1 ) );
|
||||||
|
|
||||||
encoder.setProtocol( Protocol.STATUS );
|
encoder.setProtocol( Protocol.STATUS );
|
||||||
channel.write( new StatusRequest() );
|
channel.write( new StatusRequest() );
|
||||||
|
Loading…
Reference in New Issue
Block a user