Fix issue #213 - servers crashing clients.
This commit is contained in:
parent
e07f1e603a
commit
5f7ecf9d3b
@ -5,22 +5,22 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
public class Scoreboard
|
public class Scoreboard
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique name for this scoreboard.
|
* Unique name for this scoreboard.
|
||||||
*/
|
*/
|
||||||
private final String name;
|
private String name;
|
||||||
/**
|
/**
|
||||||
* Position of this scoreboard.
|
* Position of this scoreboard.
|
||||||
*/
|
*/
|
||||||
private final Position position;
|
private Position position;
|
||||||
/**
|
/**
|
||||||
* Objectives for this scoreboard.
|
* Objectives for this scoreboard.
|
||||||
*/
|
*/
|
||||||
@ -88,4 +88,13 @@ public class Scoreboard
|
|||||||
{
|
{
|
||||||
teams.remove( teamName );
|
teams.remove( teamName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear()
|
||||||
|
{
|
||||||
|
name = null;
|
||||||
|
position = null;
|
||||||
|
objectives.clear();
|
||||||
|
scores.clear();
|
||||||
|
teams.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import net.md_5.bungee.api.config.TexturePackInfo;
|
|||||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||||
import net.md_5.bungee.api.event.ServerKickEvent;
|
import net.md_5.bungee.api.event.ServerKickEvent;
|
||||||
import net.md_5.bungee.api.scoreboard.Objective;
|
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.api.scoreboard.Team;
|
||||||
import net.md_5.bungee.connection.CancelSendSignal;
|
import net.md_5.bungee.connection.CancelSendSignal;
|
||||||
import net.md_5.bungee.connection.DownstreamBridge;
|
import net.md_5.bungee.connection.DownstreamBridge;
|
||||||
@ -23,7 +22,6 @@ import net.md_5.bungee.packet.Packet1Login;
|
|||||||
import net.md_5.bungee.packet.Packet9Respawn;
|
import net.md_5.bungee.packet.Packet9Respawn;
|
||||||
import net.md_5.bungee.packet.PacketCDClientStatus;
|
import net.md_5.bungee.packet.PacketCDClientStatus;
|
||||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
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.PacketD1Team;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
||||||
@ -114,18 +112,15 @@ public class ServerConnector extends PacketHandler
|
|||||||
{
|
{
|
||||||
bungee.getTabListHandler().onServerChange( user );
|
bungee.getTabListHandler().onServerChange( user );
|
||||||
|
|
||||||
if ( user.serverSentScoreboard != null )
|
for ( Objective objective : user.serverSentScoreboard.getObjectives() )
|
||||||
{
|
{
|
||||||
for ( Objective objective : user.serverSentScoreboard.getObjectives() )
|
user.ch.write( new PacketCEScoreboardObjective( objective.getName(), objective.getValue(), (byte) 1 ) );
|
||||||
{
|
|
||||||
user.ch.write( new PacketCEScoreboardObjective( objective.getName(), objective.getValue(), (byte) 1 ) );
|
|
||||||
}
|
|
||||||
for ( Team team : user.serverSentScoreboard.getTeams() )
|
|
||||||
{
|
|
||||||
user.ch.write( PacketD1Team.destroy( team.getName() ) );
|
|
||||||
}
|
|
||||||
user.serverSentScoreboard = null;
|
|
||||||
}
|
}
|
||||||
|
for ( Team team : user.serverSentScoreboard.getTeams() )
|
||||||
|
{
|
||||||
|
user.ch.write( PacketD1Team.destroy( team.getName() ) );
|
||||||
|
}
|
||||||
|
user.serverSentScoreboard.clear();
|
||||||
|
|
||||||
user.sendPacket( Packet9Respawn.DIM1_SWITCH );
|
user.sendPacket( Packet9Respawn.DIM1_SWITCH );
|
||||||
user.sendPacket( Packet9Respawn.DIM2_SWITCH );
|
user.sendPacket( Packet9Respawn.DIM2_SWITCH );
|
||||||
|
@ -62,7 +62,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
@Getter
|
@Getter
|
||||||
private final Object switchMutex = new Object();
|
private final Object switchMutex = new Object();
|
||||||
public PacketCCSettings settings;
|
public PacketCCSettings settings;
|
||||||
public Scoreboard serverSentScoreboard;
|
public final Scoreboard serverSentScoreboard = new Scoreboard();
|
||||||
|
|
||||||
public UserConnection(BungeeCord bungee, Channel channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List<PacketFAPluginMessage> loginMessages)
|
public UserConnection(BungeeCord bungee, Channel channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List<PacketFAPluginMessage> loginMessages)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,6 @@ import net.md_5.bungee.api.scoreboard.Scoreboard;
|
|||||||
import net.md_5.bungee.api.scoreboard.Team;
|
import net.md_5.bungee.api.scoreboard.Team;
|
||||||
import net.md_5.bungee.packet.Packet0KeepAlive;
|
import net.md_5.bungee.packet.Packet0KeepAlive;
|
||||||
import net.md_5.bungee.packet.Packet3Chat;
|
import net.md_5.bungee.packet.Packet3Chat;
|
||||||
import net.md_5.bungee.packet.Packet9Respawn;
|
|
||||||
import net.md_5.bungee.packet.PacketC9PlayerListItem;
|
import net.md_5.bungee.packet.PacketC9PlayerListItem;
|
||||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
||||||
import net.md_5.bungee.packet.PacketCFScoreboardScore;
|
import net.md_5.bungee.packet.PacketCFScoreboardScore;
|
||||||
@ -106,75 +105,67 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
||||||
{
|
{
|
||||||
if ( con.serverSentScoreboard != null )
|
switch ( objective.action )
|
||||||
{
|
{
|
||||||
switch ( objective.action )
|
case 0:
|
||||||
{
|
con.serverSentScoreboard.addObjective( new Objective( objective.name, objective.text ) );
|
||||||
case 0:
|
break;
|
||||||
con.serverSentScoreboard.addObjective( new Objective( objective.name, objective.text ) );
|
case 1:
|
||||||
break;
|
con.serverSentScoreboard.removeObjective( objective.name );
|
||||||
case 1:
|
break;
|
||||||
con.serverSentScoreboard.removeObjective( objective.name );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketCFScoreboardScore score) throws Exception
|
public void handle(PacketCFScoreboardScore score) throws Exception
|
||||||
{
|
{
|
||||||
if ( con.serverSentScoreboard != null )
|
switch ( score.action )
|
||||||
{
|
{
|
||||||
switch ( score.action )
|
case 0:
|
||||||
{
|
con.serverSentScoreboard.addScore( new Score( score.itemName, score.scoreName, score.value ) );
|
||||||
case 0:
|
break;
|
||||||
con.serverSentScoreboard.addScore( new Score( score.itemName, score.scoreName, score.value ) );
|
case 1:
|
||||||
break;
|
con.serverSentScoreboard.removeScore( score.itemName );
|
||||||
case 1:
|
break;
|
||||||
con.serverSentScoreboard.removeScore( score.itemName );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
||||||
{
|
{
|
||||||
con.serverSentScoreboard = new Scoreboard( displayScoreboard.name, Position.values()[displayScoreboard.position] );
|
con.serverSentScoreboard.setName( displayScoreboard.name );
|
||||||
|
con.serverSentScoreboard.setPosition( Position.values()[displayScoreboard.position] );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketD1Team team) throws Exception
|
public void handle(PacketD1Team team) throws Exception
|
||||||
{
|
{
|
||||||
if ( con.serverSentScoreboard != null )
|
// Remove team and move on
|
||||||
|
if ( team.mode == 1 )
|
||||||
{
|
{
|
||||||
// Remove team and move on
|
con.serverSentScoreboard.removeTeam( team.name );
|
||||||
if ( team.mode == 1 )
|
return;
|
||||||
{
|
}
|
||||||
con.serverSentScoreboard.removeTeam( team.name );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create or get old team
|
// Create or get old team
|
||||||
Team t = ( team.mode == 0 ) ? new Team( team.name ) : con.serverSentScoreboard.getTeam( team.name );
|
Team t = ( team.mode == 0 ) ? new Team( team.name ) : con.serverSentScoreboard.getTeam( team.name );
|
||||||
if ( t != null )
|
if ( t != null )
|
||||||
|
{
|
||||||
|
if ( team.mode == 0 || team.mode == 2 )
|
||||||
{
|
{
|
||||||
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.setDisplayName( team.displayName );
|
t.addPlayer( s );
|
||||||
t.setPrefix( team.prefix );
|
} else
|
||||||
t.setSuffix( team.suffix );
|
|
||||||
t.setFriendlyMode( team.friendlyFire );
|
|
||||||
}
|
|
||||||
for ( String s : team.players )
|
|
||||||
{
|
{
|
||||||
if ( team.mode == 0 || team.mode == 3 )
|
t.removePlayer( s );
|
||||||
{
|
|
||||||
t.addPlayer( s );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
t.removePlayer( s );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class PacketD0DisplayScoreboard extends DefinedPacket
|
|||||||
|
|
||||||
public PacketD0DisplayScoreboard(byte[] buf)
|
public PacketD0DisplayScoreboard(byte[] buf)
|
||||||
{
|
{
|
||||||
super( 0xCF, buf );
|
super( 0xD0, buf );
|
||||||
position = readByte();
|
position = readByte();
|
||||||
name = readUTF();
|
name = readUTF();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user