[#1649] Don't parse disconnect reason for servers.

Reported by @kamcio96
This commit is contained in:
md_5 2016-01-16 12:29:13 +11:00
parent f5552963b8
commit 2c86592ecd

View File

@ -1,18 +1,16 @@
package net.md_5.bungee; package net.md_5.bungee;
import com.google.common.base.Preconditions;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.Setter;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.chat.ComponentSerializer;
import net.md_5.bungee.netty.ChannelWrapper; import net.md_5.bungee.netty.ChannelWrapper;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.Kick;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ServerConnection implements Server public class ServerConnection implements Server
@ -46,12 +44,14 @@ public class ServerConnection implements Server
@Override @Override
public void disconnect(String reason) public void disconnect(String reason)
{ {
disconnect( TextComponent.fromLegacyText( reason ) ); disconnect();
} }
@Override @Override
public synchronized void disconnect(BaseComponent... reason) public synchronized void disconnect(BaseComponent... reason)
{ {
Preconditions.checkArgument( reason.length == 0, "Server cannot have disconnect reason" );
if ( !ch.isClosed() ) if ( !ch.isClosed() )
{ {
ch.getHandle().eventLoop().schedule( new Runnable() ch.getHandle().eventLoop().schedule( new Runnable()
@ -63,16 +63,12 @@ public class ServerConnection implements Server
} }
}, 100, TimeUnit.MILLISECONDS ); }, 100, TimeUnit.MILLISECONDS );
} }
} }
@Override @Override
public void disconnect(BaseComponent reason) public void disconnect(BaseComponent reason)
{ {
disconnect( new BaseComponent[] disconnect();
{
reason
} );
} }
@Override @Override