mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-25 18:17:38 +01:00
Revert disconnect change. Forgot we use void futures.
This commit is contained in:
parent
98a5db9abf
commit
9a4f0a6f59
@ -1,7 +1,7 @@
|
||||
package net.md_5.bungee;
|
||||
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -41,7 +41,7 @@ public class ServerConnection implements Server
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String reason)
|
||||
public synchronized void disconnect(String reason)
|
||||
{
|
||||
disconnect( TextComponent.fromLegacyText( reason ) );
|
||||
}
|
||||
@ -49,7 +49,20 @@ public class ServerConnection implements Server
|
||||
@Override
|
||||
public void disconnect(BaseComponent... reason)
|
||||
{
|
||||
ch.write( new Kick( ComponentSerializer.toString( reason ) ), ChannelFutureListener.CLOSE );
|
||||
if ( !ch.isClosed() )
|
||||
{
|
||||
// TODO: Can we just use a future here?
|
||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||
ch.getHandle().eventLoop().schedule( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
ch.getHandle().close();
|
||||
}
|
||||
}, 100, TimeUnit.MILLISECONDS );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,8 +3,6 @@ package net.md_5.bungee.netty;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.Getter;
|
||||
@ -36,32 +34,22 @@ public class ChannelWrapper
|
||||
ch.pipeline().get( MinecraftEncoder.class ).setProtocolVersion( protocol );
|
||||
}
|
||||
|
||||
public synchronized void write(Object packet, ChannelFutureListener future)
|
||||
public synchronized void write(Object packet)
|
||||
{
|
||||
if ( !closed )
|
||||
{
|
||||
ChannelFuture listener;
|
||||
if ( packet instanceof PacketWrapper )
|
||||
{
|
||||
( (PacketWrapper) packet ).setReleased( true );
|
||||
listener = ch.write( ( (PacketWrapper) packet ).buf, ch.voidPromise() );
|
||||
ch.write( ( (PacketWrapper) packet ).buf, ch.voidPromise() );
|
||||
} else
|
||||
{
|
||||
listener = ch.write( packet, ch.voidPromise() );
|
||||
}
|
||||
if ( future != null )
|
||||
{
|
||||
listener.addListener( future );
|
||||
ch.write( packet, ch.voidPromise() );
|
||||
}
|
||||
ch.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void write(Object packet)
|
||||
{
|
||||
write( packet, null );
|
||||
}
|
||||
|
||||
public synchronized void close()
|
||||
{
|
||||
if ( !closed )
|
||||
|
Loading…
Reference in New Issue
Block a user