diff --git a/proxy/src/main/java/net/md_5/bungee/KickException.java b/proxy/src/main/java/net/md_5/bungee/KickException.java deleted file mode 100644 index 5b495e00..00000000 --- a/proxy/src/main/java/net/md_5/bungee/KickException.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.md_5.bungee; - -/** - * Exception, which when thrown will disconnect the player from the proxy with - * the specified message. - */ -public class KickException extends RuntimeException -{ - - public KickException(String message) - { - super( message ); - } -} 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 6a55e2c9..c74b124b 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -34,6 +34,11 @@ public class ServerConnection implements Server @Override public synchronized void disconnect(String reason) + { + disconnect( ch, reason ); + } + + static void disconnect(final Channel ch, String reason) { if ( ch.isActive() ) { 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 bc21a10f..9c138201 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import io.netty.channel.Channel; import java.util.Queue; import lombok.RequiredArgsConstructor; +import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.event.ServerConnectedEvent; @@ -125,7 +126,14 @@ public class ServerConnector extends PacketHandler @Override public void handle(PacketFFKick kick) throws Exception { - throw new KickException( kick.message ); + String message = ChatColor.RED + "Kicked whilst connecting to " + target.getName() + ": " + kick.message; + if ( user.getServer() == null ) + { + user.disconnect( message ); + } else + { + user.sendMessage( message ); + } } @Override