From 2ae8ba0afc68215d4c702067d13abdd62a774539 Mon Sep 17 00:00:00 2001 From: Mystiflow Date: Fri, 4 Aug 2017 07:10:10 +0100 Subject: [PATCH] Various scoreboard improvements. (#2204) - Correctly remove objectives that use heart type. - Also sends remove score packets on server switch. - Players are only removed if Team packet mode is 4. --- .../main/java/net/md_5/bungee/api/score/Objective.java | 2 +- proxy/src/main/java/net/md_5/bungee/ServerConnector.java | 8 +++++++- .../java/net/md_5/bungee/connection/DownstreamBridge.java | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/score/Objective.java b/api/src/main/java/net/md_5/bungee/api/score/Objective.java index b1afa57ec..0dd256467 100644 --- a/api/src/main/java/net/md_5/bungee/api/score/Objective.java +++ b/api/src/main/java/net/md_5/bungee/api/score/Objective.java @@ -22,5 +22,5 @@ public class Objective /** * Type; integer or hearts */ - private final String type; + private String type; } diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 2014b0c49..111ee8b43 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -15,6 +15,7 @@ import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.event.ServerKickEvent; import net.md_5.bungee.api.event.ServerSwitchEvent; import net.md_5.bungee.api.score.Objective; +import net.md_5.bungee.api.score.Score; import net.md_5.bungee.api.score.Scoreboard; import net.md_5.bungee.api.score.Team; import net.md_5.bungee.chat.ComponentSerializer; @@ -37,6 +38,7 @@ import net.md_5.bungee.protocol.packet.LoginSuccess; import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.ScoreboardObjective; +import net.md_5.bungee.protocol.packet.ScoreboardScore; import net.md_5.bungee.protocol.packet.SetCompression; @RequiredArgsConstructor @@ -209,7 +211,11 @@ public class ServerConnector extends PacketHandler Scoreboard serverScoreboard = user.getServerSentScoreboard(); for ( Objective objective : serverScoreboard.getObjectives() ) { - user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), "integer", (byte) 1 ) ); // TODO: + user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), objective.getType(), (byte) 1 ) ); + } + for ( Score score : serverScoreboard.getScores() ) + { + user.unsafe().sendPacket( new ScoreboardScore( score.getItemName(), (byte) 1, score.getScoreName(), score.getValue() ) ); } for ( Team team : serverScoreboard.getTeams() ) { diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index c2dd942ff..57fe06e5b 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -135,6 +135,7 @@ public class DownstreamBridge extends PacketHandler if ( oldObjective != null ) { oldObjective.setValue( objective.getValue() ); + oldObjective.setType( objective.getType() ); } break; default: @@ -210,7 +211,7 @@ public class DownstreamBridge extends PacketHandler if ( team.getMode() == 0 || team.getMode() == 3 ) { t.addPlayer( s ); - } else + } else if ( team.getMode() == 4 ) { t.removePlayer( s ); }