mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-25 10:07:38 +01:00
Try and make the client not crash when switching teams. @lazertester
This commit is contained in:
parent
fd062503e1
commit
73aaf58009
@ -21,4 +21,14 @@ public class Team
|
||||
{
|
||||
return Collections.unmodifiableSet( players );
|
||||
}
|
||||
|
||||
public void addPlayer(String name)
|
||||
{
|
||||
players.add( name );
|
||||
}
|
||||
|
||||
public void removePlayer(String name)
|
||||
{
|
||||
players.remove( name );
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.event.ServerKickEvent;
|
||||
import net.md_5.bungee.api.scoreboard.Objective;
|
||||
import net.md_5.bungee.api.scoreboard.Score;
|
||||
import net.md_5.bungee.api.scoreboard.Team;
|
||||
import net.md_5.bungee.connection.CancelSendSignal;
|
||||
import net.md_5.bungee.connection.DownstreamBridge;
|
||||
import net.md_5.bungee.netty.HandlerBoss;
|
||||
@ -23,6 +24,7 @@ import net.md_5.bungee.packet.Packet9Respawn;
|
||||
import net.md_5.bungee.packet.PacketCDClientStatus;
|
||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
||||
import net.md_5.bungee.packet.PacketCFScoreboardScore;
|
||||
import net.md_5.bungee.packet.PacketD1Team;
|
||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
||||
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
||||
import net.md_5.bungee.packet.PacketFFKick;
|
||||
@ -122,6 +124,10 @@ public class ServerConnector extends PacketHandler
|
||||
{
|
||||
user.ch.write( new PacketCFScoreboardScore( score.getItemName(), (byte) 1, null, 0 ) );
|
||||
}
|
||||
for ( Team team : user.serverSentScoreboard.getTeams() )
|
||||
{
|
||||
user.ch.write( PacketD1Team.destroy( team.getName() ) );
|
||||
}
|
||||
user.serverSentScoreboard = null;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import net.md_5.bungee.api.scoreboard.Objective;
|
||||
import net.md_5.bungee.api.scoreboard.Position;
|
||||
import net.md_5.bungee.api.scoreboard.Score;
|
||||
import net.md_5.bungee.api.scoreboard.Scoreboard;
|
||||
import net.md_5.bungee.api.scoreboard.Team;
|
||||
import net.md_5.bungee.packet.Packet0KeepAlive;
|
||||
import net.md_5.bungee.packet.Packet3Chat;
|
||||
import net.md_5.bungee.packet.Packet9Respawn;
|
||||
@ -27,6 +28,7 @@ import net.md_5.bungee.packet.PacketC9PlayerListItem;
|
||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
||||
import net.md_5.bungee.packet.PacketCFScoreboardScore;
|
||||
import net.md_5.bungee.packet.PacketD0DisplayScoreboard;
|
||||
import net.md_5.bungee.packet.PacketD1Team;
|
||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
||||
import net.md_5.bungee.packet.PacketFFKick;
|
||||
import net.md_5.bungee.packet.PacketHandler;
|
||||
@ -141,6 +143,43 @@ public class DownstreamBridge extends PacketHandler
|
||||
con.serverSentScoreboard = new Scoreboard( displayScoreboard.name, Position.values()[displayScoreboard.position] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketD1Team team) throws Exception
|
||||
{
|
||||
if ( con.serverSentScoreboard != null )
|
||||
{
|
||||
// Remove team and move on
|
||||
if ( team.mode == 1 )
|
||||
{
|
||||
con.serverSentScoreboard.removeTeam( team.name );
|
||||
return;
|
||||
}
|
||||
|
||||
// Create or get old team
|
||||
Team t = ( team.mode == 0 ) ? new Team( team.name ) : con.serverSentScoreboard.getTeam( team.name );
|
||||
if ( t != null )
|
||||
{
|
||||
if ( team.mode == 0 || team.mode == 2 )
|
||||
{
|
||||
t.setDisplayName( team.displayName );
|
||||
t.setPrefix( team.prefix );
|
||||
t.setSuffix( team.suffix );
|
||||
t.setFriendlyMode( team.friendlyFire );
|
||||
}
|
||||
for ( String s : team.players )
|
||||
{
|
||||
if ( team.mode == 0 || team.mode == 3 )
|
||||
{
|
||||
t.addPlayer( s );
|
||||
} else
|
||||
{
|
||||
t.removePlayer( s );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||
{
|
||||
|
@ -42,6 +42,19 @@ public class PacketD1Team extends DefinedPacket
|
||||
}
|
||||
}
|
||||
|
||||
public PacketD1Team()
|
||||
{
|
||||
super( 0xD1 );
|
||||
}
|
||||
|
||||
public static PacketD1Team destroy(String name)
|
||||
{
|
||||
PacketD1Team packet = new PacketD1Team();
|
||||
packet.writeUTF( name );
|
||||
packet.writeByte( 1 );
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user