use of net.minecraft.network.protocol.game.ClientboundSetScorePacket in project Denizen-For-Bukkit by DenizenScript.
the class SidebarImpl method sendUpdate.
@Override
public void sendUpdate() {
List<PlayerTeam> oldTeams = generatedTeams;
generatedTeams = new ArrayList<>();
PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj1, 0));
for (int i = 0; i < this.lines.length; i++) {
String line = this.lines[i];
if (line == null) {
break;
}
String lineId = Utilities.generateRandomColors(8);
PlayerTeam team = new PlayerTeam(dummyScoreboard, lineId);
team.getPlayers().add(lineId);
team.setPlayerPrefix(Handler.componentToNMS(FormattedTextHelper.parse(line, ChatColor.WHITE)));
generatedTeams.add(team);
PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true));
PacketHelperImpl.send(player, new ClientboundSetScorePacket(ServerScoreboard.Method.CHANGE, obj1.getName(), lineId, this.scores[i]));
}
PacketHelperImpl.send(player, new ClientboundSetDisplayObjectivePacket(1, this.obj1));
PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj2, 1));
Objective temp = this.obj2;
this.obj2 = this.obj1;
this.obj1 = temp;
for (PlayerTeam team : oldTeams) {
PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createRemovePacket(team));
}
}
use of net.minecraft.network.protocol.game.ClientboundSetScorePacket in project SpongeCommon by SpongePowered.
the class ServerScoreboardMixin method bridge$addPlayer.
@Override
public void bridge$addPlayer(final ServerPlayer player, final boolean sendPackets) {
this.impl$players.add(player);
if (sendPackets) {
for (final PlayerTeam team : this.getPlayerTeams()) {
player.connection.send(new ClientboundSetPlayerTeamPacket(team, 0));
}
for (final net.minecraft.world.scores.Objective objective : this.getObjectives()) {
player.connection.send(new ClientboundSetObjectivePacket(objective, 0));
for (int i = 0; i < 19; ++i) {
if (this.getDisplayObjective(i) == objective) {
player.connection.send(new ClientboundSetDisplayObjectivePacket(i, objective));
}
}
for (final Score score : this.getPlayerScores(objective)) {
final ClientboundSetScorePacket packetIn = new ClientboundSetScorePacket(Method.CHANGE, score.getObjective().getName(), score.getOwner(), score.getScore());
player.connection.send(packetIn);
}
}
}
}
use of net.minecraft.network.protocol.game.ClientboundSetScorePacket in project Denizen-For-Bukkit by DenizenScript.
the class SidebarImpl method sendUpdate.
@Override
public void sendUpdate() {
List<PlayerTeam> oldTeams = generatedTeams;
generatedTeams = new ArrayList<>();
PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj1, 0));
for (int i = 0; i < this.lines.length; i++) {
String line = this.lines[i];
if (line == null) {
break;
}
String lineId = Utilities.generateRandomColors(8);
PlayerTeam team = new PlayerTeam(dummyScoreboard, lineId);
team.getPlayers().add(lineId);
team.setPlayerPrefix(Handler.componentToNMS(FormattedTextHelper.parse(line, ChatColor.WHITE)));
generatedTeams.add(team);
PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true));
PacketHelperImpl.send(player, new ClientboundSetScorePacket(ServerScoreboard.Method.CHANGE, obj1.getName(), lineId, this.scores[i]));
}
PacketHelperImpl.send(player, new ClientboundSetDisplayObjectivePacket(1, this.obj1));
PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj2, 1));
Objective temp = this.obj2;
this.obj2 = this.obj1;
this.obj1 = temp;
for (PlayerTeam team : oldTeams) {
PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createRemovePacket(team));
}
}
Aggregations