Fix scoreboards / tab lists getting out of sync due to race conditions / overlap.

This commit is contained in:
md_5 2016-02-19 09:07:12 +11:00
parent afc02082e6
commit 0646a3090a
4 changed files with 17 additions and 9 deletions

View File

@ -207,6 +207,7 @@ public class ServerConnector extends PacketHandler
} }
} else } else
{ {
user.getServer().setObsolete( true );
user.getTabListHandler().onServerChange(); user.getTabListHandler().onServerChange();
Scoreboard serverScoreboard = user.getServerSentScoreboard(); Scoreboard serverScoreboard = user.getServerSentScoreboard();
@ -226,7 +227,6 @@ public class ServerConnector extends PacketHandler
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) ); user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
// Remove from old servers // Remove from old servers
user.getServer().setObsolete( true );
user.getServer().disconnect( "Quitting" ); user.getServer().disconnect( "Quitting" );
} }

View File

@ -89,14 +89,17 @@ public class DownstreamBridge extends PacketHandler
bungee.getPluginManager().callEvent( serverDisconnectEvent ); bungee.getPluginManager().callEvent( serverDisconnectEvent );
} }
@Override
public boolean shouldHandle(PacketWrapper packet) throws Exception
{
return !server.isObsolete();
}
@Override @Override
public void handle(PacketWrapper packet) throws Exception public void handle(PacketWrapper packet) throws Exception
{ {
if ( !server.isObsolete() ) con.getEntityRewrite().rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId() );
{ con.sendPacket( packet );
con.getEntityRewrite().rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId() );
con.sendPacket( packet );
}
} }
@Override @Override
@ -451,7 +454,7 @@ public class DownstreamBridge extends PacketHandler
con.getServer().sendData( "BungeeCord", b ); con.getServer().sendData( "BungeeCord", b );
} }
} }
throw CancelSendSignal.INSTANCE; throw CancelSendSignal.INSTANCE;
} }
} }

View File

@ -66,10 +66,10 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
if ( handler != null ) if ( handler != null )
{ {
PacketWrapper packet = (PacketWrapper) msg; PacketWrapper packet = (PacketWrapper) msg;
boolean sendPacket = true; boolean sendPacket = handler.shouldHandle( packet );
try try
{ {
if ( packet.packet != null ) if ( sendPacket && packet.packet != null )
{ {
try try
{ {

View File

@ -8,6 +8,11 @@ public abstract class PacketHandler extends net.md_5.bungee.protocol.AbstractPac
@Override @Override
public abstract String toString(); public abstract String toString();
public boolean shouldHandle(PacketWrapper packet) throws Exception
{
return true;
}
public void exception(Throwable t) throws Exception public void exception(Throwable t) throws Exception
{ {
} }