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,8 +112,6 @@ 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 ) );
|
||||||
@ -124,8 +120,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
{
|
{
|
||||||
user.ch.write( PacketD1Team.destroy( team.getName() ) );
|
user.ch.write( PacketD1Team.destroy( team.getName() ) );
|
||||||
}
|
}
|
||||||
user.serverSentScoreboard = null;
|
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;
|
||||||
@ -105,8 +104,6 @@ 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 )
|
||||||
{
|
{
|
||||||
@ -118,12 +115,9 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
break;
|
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 )
|
||||||
{
|
{
|
||||||
@ -135,18 +129,16 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
break;
|
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
|
// Remove team and move on
|
||||||
if ( team.mode == 1 )
|
if ( team.mode == 1 )
|
||||||
@ -178,7 +170,6 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||||
|
@ -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