Handle kicks when trying to login to server. Now we have to be about done.
This commit is contained in:
parent
76319371f7
commit
9fb814003b
@ -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 );
|
||||
}
|
||||
}
|
@ -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() )
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user