Remove switchMutex since its no longer required

This commit is contained in:
md_5 2014-02-27 07:32:23 +11:00
parent 37ed331515
commit 565af4d53e
2 changed files with 49 additions and 54 deletions

View File

@ -117,67 +117,64 @@ public class ServerConnector extends PacketHandler
ch.write( user.getSettings() ); ch.write( user.getSettings() );
} }
synchronized ( user.getSwitchMutex() ) if ( user.getServer() == null )
{ {
if ( user.getServer() == null ) // Once again, first connection
user.setClientEntityId( login.getEntityId() );
user.setServerEntityId( login.getEntityId() );
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
Login modLogin = new Login( login.getEntityId(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(),
(byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType() );
user.unsafe().sendPacket( modLogin );
MinecraftOutput out = new MinecraftOutput();
out.writeStringUTF8WithoutLengthHeaderBecauseDinnerboneStuffedUpTheMCBrandPacket( ProxyServer.getInstance().getName() + " (" + ProxyServer.getInstance().getVersion() + ")" );
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", out.toArray() ) );
} else
{
user.getTabList().onServerChange();
Scoreboard serverScoreboard = user.getServerSentScoreboard();
for ( Objective objective : serverScoreboard.getObjectives() )
{ {
// Once again, first connection user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), (byte) 1 ) );
user.setClientEntityId( login.getEntityId() );
user.setServerEntityId( login.getEntityId() );
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
Login modLogin = new Login( login.getEntityId(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(),
(byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType() );
user.unsafe().sendPacket( modLogin );
MinecraftOutput out = new MinecraftOutput();
out.writeStringUTF8WithoutLengthHeaderBecauseDinnerboneStuffedUpTheMCBrandPacket( ProxyServer.getInstance().getName() + " (" + ProxyServer.getInstance().getVersion() + ")" );
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", out.toArray() ) );
} else
{
user.getTabList().onServerChange();
Scoreboard serverScoreboard = user.getServerSentScoreboard();
for ( Objective objective : serverScoreboard.getObjectives() )
{
user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), (byte) 1 ) );
}
for ( Team team : serverScoreboard.getTeams() )
{
user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.Team( team.getName() ) );
}
serverScoreboard.clear();
user.sendDimensionSwitch();
user.setServerEntityId( login.getEntityId() );
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
// Remove from old servers
user.getServer().setObsolete( true );
user.getServer().disconnect( "Quitting" );
} }
for ( Team team : serverScoreboard.getTeams() )
// TODO: Fix this?
if ( !user.isActive() )
{ {
server.disconnect( "Quitting" ); user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.Team( team.getName() ) );
// Silly server admins see stack trace and die
bungee.getLogger().warning( "No client connected for pending server!" );
return;
} }
serverScoreboard.clear();
// Add to new server user.sendDimensionSwitch();
// TODO: Move this to the connected() method of DownstreamBridge
target.addPlayer( user );
user.getPendingConnects().remove( target );
user.setDimensionChange( false );
user.setServer( server ); user.setServerEntityId( login.getEntityId() );
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new DownstreamBridge( bungee, user, server ) ); user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
// Remove from old servers
user.getServer().setObsolete( true );
user.getServer().disconnect( "Quitting" );
} }
// TODO: Fix this?
if ( !user.isActive() )
{
server.disconnect( "Quitting" );
// Silly server admins see stack trace and die
bungee.getLogger().warning( "No client connected for pending server!" );
return;
}
// Add to new server
// TODO: Move this to the connected() method of DownstreamBridge
target.addPlayer( user );
user.getPendingConnects().remove( target );
user.setDimensionChange( false );
user.setServer( server );
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new DownstreamBridge( bungee, user, server ) );
bungee.getPluginManager().callEvent( new ServerSwitchEvent( user ) ); bungee.getPluginManager().callEvent( new ServerSwitchEvent( user ) );
thisState = State.FINISHED; thisState = State.FINISHED;

View File

@ -67,8 +67,6 @@ public final class UserConnection implements ProxiedPlayer
@Setter @Setter
private boolean dimensionChange = true; private boolean dimensionChange = true;
@Getter @Getter
private final Object switchMutex = new Object();
@Getter
private final Collection<ServerInfo> pendingConnects = new HashSet<>(); private final Collection<ServerInfo> pendingConnects = new HashSet<>();
/*========================================================================*/ /*========================================================================*/
@Getter @Getter