From fa5804ec86a58f0f35abcfaecb0e321f34029c3c Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 11 Mar 2013 09:18:39 +1100 Subject: [PATCH] OMG WTF BBQ IT WORKS. LETS IRON OUT BUGS AND GET OUR RELEASE TARGET, ONLY 12 HOURS LEFT. --- api/src/main/java/net/md_5/bungee/api/connection/Server.java | 2 -- proxy/src/main/java/net/md_5/bungee/ServerConnection.java | 4 ++++ proxy/src/main/java/net/md_5/bungee/ServerConnector.java | 3 ++- .../java/net/md_5/bungee/connection/DownstreamBridge.java | 5 ++++- .../main/java/net/md_5/bungee/connection/UpstreamBridge.java | 1 - 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/connection/Server.java b/api/src/main/java/net/md_5/bungee/api/connection/Server.java index 58ae7a1fc..06eb6d1af 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/Server.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/Server.java @@ -1,7 +1,5 @@ package net.md_5.bungee.api.connection; -import net.md_5.bungee.api.Callback; -import net.md_5.bungee.api.ServerPing; import net.md_5.bungee.api.config.ServerInfo; /** 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 ce31f3046..6ce751a59 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -4,6 +4,7 @@ import io.netty.channel.Channel; import java.net.InetSocketAddress; import lombok.Getter; import lombok.RequiredArgsConstructor; +import lombok.Setter; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.packet.Packet1Login; @@ -20,6 +21,9 @@ public class ServerConnection implements Server private final ServerInfo info; @Getter private final Packet1Login loginPacket; + @Getter + @Setter + private boolean isObsolete; @Override public void sendData(String channel, byte[] data) diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 1b1594fd0..152b8424a 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -91,11 +91,12 @@ public class ServerConnector extends PacketHandler user.ch.write( new Packet9Respawn( login.dimension, login.difficulty, login.gameMode, (short) 256, login.levelType ) ); // Remove from old servers + user.getServer().setObsolete( true ); user.getServer().disconnect( "Quitting" ); - user.getServer().getInfo().removePlayer( user ); } // Add to new server + // TODO: Move this to the connected() method of DownstreamBridge target.addPlayer( user ); user.setServer( server ); 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 fc1613266..1d4223c16 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 @@ -7,6 +7,7 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import lombok.RequiredArgsConstructor; import net.md_5.bungee.EntityMap; +import net.md_5.bungee.ServerConnection; import net.md_5.bungee.UserConnection; import net.md_5.bungee.Util; import net.md_5.bungee.api.ProxyServer; @@ -28,7 +29,7 @@ public class DownstreamBridge extends PacketHandler private final ProxyServer bungee; private final UserConnection con; - private final Server server; + private final ServerConnection server; @Override public void exception(Throwable t) throws Exception @@ -43,7 +44,9 @@ public class DownstreamBridge extends PacketHandler server.getInfo().removePlayer( con ); bungee.getReconnectHandler().setServer( con ); + if (!server.isObsolete()){ con.disconnect( "[Proxy] Lost connection to server D:" ); + } } @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 d71a0ef3c..b503116dd 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 @@ -41,7 +41,6 @@ public class UpstreamBridge extends PacketHandler { con.getServer().disconnect( "Quitting" ); } - } @Override