mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-24 11:15:47 +01:00
Ensure all resources are closed all the time.
This commit is contained in:
parent
3be83cb5a4
commit
6e18403cd9
@ -144,20 +144,9 @@ public final class UserConnection implements ProxiedPlayer
|
||||
{
|
||||
if ( ch.isActive() )
|
||||
{
|
||||
PlayerDisconnectEvent event = new PlayerDisconnectEvent( this );
|
||||
bungee.getPluginManager().callEvent( event );
|
||||
bungee.getTabListHandler().onDisconnect( this );
|
||||
bungee.getPlayers().remove( this );
|
||||
|
||||
ch.write( new PacketFFKick( reason ) );
|
||||
ch.close();
|
||||
|
||||
if ( server != null )
|
||||
{
|
||||
server.getInfo().removePlayer( this );
|
||||
server.disconnect( "Quitting" );
|
||||
bungee.getReconnectHandler().setServer( this );
|
||||
}
|
||||
server.disconnect( "Quitting" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.EntityMap;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
@ -35,12 +36,20 @@ public class DownstreamBridge extends PacketHandler
|
||||
con.disconnect( Util.exception( t ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected(Channel channel) throws Exception
|
||||
{
|
||||
// We lost connection to the server
|
||||
server.getInfo().removePlayer( con );
|
||||
bungee.getReconnectHandler().setServer( con );
|
||||
|
||||
con.disconnect( "[Proxy] Lost connection to server D:" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ByteBuf buf) throws Exception
|
||||
{
|
||||
EntityMap.rewrite( buf, con.serverEntityId, con.clientEntityId );
|
||||
System.out.println( "Got packet from server: " + Util.hex( buf.getUnsignedByte( 0 ) ) );
|
||||
System.out.println( buf );
|
||||
con.ch.write( buf );
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.EntityMap;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.Util;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.packet.Packet0KeepAlive;
|
||||
import net.md_5.bungee.packet.Packet3Chat;
|
||||
@ -26,11 +28,26 @@ public class UpstreamBridge extends PacketHandler
|
||||
con.disconnect( Util.exception( t ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected(Channel channel) throws Exception
|
||||
{
|
||||
// We lost connection to the client
|
||||
PlayerDisconnectEvent event = new PlayerDisconnectEvent( con );
|
||||
bungee.getPluginManager().callEvent( event );
|
||||
bungee.getTabListHandler().onDisconnect( con );
|
||||
bungee.getPlayers().remove( con );
|
||||
|
||||
if ( con.getServer() != null )
|
||||
{
|
||||
con.getServer().disconnect( "Quitting" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ByteBuf buf) throws Exception
|
||||
{
|
||||
EntityMap.rewrite( buf, con.clientEntityId, con.serverEntityId );
|
||||
System.out.println( "Got packet from client: " + Util.hex( buf.getUnsignedByte( 0 ) ) );
|
||||
if ( con.getServer() != null )
|
||||
{
|
||||
con.getServer().getCh().write( buf );
|
||||
|
Loading…
Reference in New Issue
Block a user