diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java index b795bf9052..285e5b8f82 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -25,6 +25,9 @@ public class ServerConnection implements Server private boolean isObsolete; @Getter private final boolean forgeServer = false; + @Getter + @Setter + private long sentPingId = -1; private final Unsafe unsafe = new Unsafe() { diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 49167c8054..2ef0d74d8c 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -90,9 +90,6 @@ public final class UserConnection implements ProxiedPlayer /*========================================================================*/ @Getter @Setter - private long sentPingId; - @Getter - @Setter private long sentPingTime; @Getter @Setter diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index 19ae627479..253126a829 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -104,8 +104,8 @@ public void handle(PacketWrapper packet) throws Exception @Override public void handle(KeepAlive alive) throws Exception { - con.setSentPingId(alive.getRandomId()); - con.setSentPingTime(System.currentTimeMillis()); + server.setSentPingId( alive.getRandomId() ); + con.setSentPingTime( System.currentTimeMillis() ); } @Override diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index 55c9804968..52e2ca17e1 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -119,11 +119,14 @@ public void handle(PacketWrapper packet) throws Exception @Override public void handle(KeepAlive alive) throws Exception { - if ( alive.getRandomId() == con.getSentPingId() ) + if ( alive.getRandomId() == con.getServer().getSentPingId() ) { int newPing = (int) ( System.currentTimeMillis() - con.getSentPingTime() ); con.getTabListHandler().onPingChange( newPing ); con.setPing( newPing ); + } else + { + throw CancelSendSignal.INSTANCE; } }