protected void sendScoreboard(ServerScoreboard scoreboardIn, EntityPlayerMP playerIn) { Set<ScoreObjective> set = Sets.<ScoreObjective>newHashSet(); for (ScorePlayerTeam scoreplayerteam : scoreboardIn.getTeams()) { playerIn.connection.sendPacket(new SPacketTeams(scoreplayerteam, 0)); } for (int i = 0; i < 19; ++i) { ScoreObjective scoreobjective = scoreboardIn.getObjectiveInDisplaySlot(i); if (scoreobjective != null && !set.contains(scoreobjective)) { for (Packet<?> packet : scoreboardIn.getCreatePackets(scoreobjective)) { playerIn.connection.sendPacket(packet); } set.add(scoreobjective); } } }
/** * Adds a player to the given team */ public boolean addPlayerToTeam(String player, String newTeam) { if (super.addPlayerToTeam(player, newTeam)) { ScorePlayerTeam scoreplayerteam = this.getTeam(newTeam); this.scoreboardMCServer.getPlayerList().sendPacketToAllPlayers(new SPacketTeams(scoreplayerteam, Arrays.asList(new String[] {player}), 3)); this.markSaveDataDirty(); return true; } else { return false; } }
/** * Removes the given username from the given ScorePlayerTeam. If the player is not on the team then an * IllegalStateException is thrown. */ public void removePlayerFromTeam(String username, ScorePlayerTeam playerTeam) { super.removePlayerFromTeam(username, playerTeam); this.scoreboardMCServer.getPlayerList().sendPacketToAllPlayers(new SPacketTeams(playerTeam, Arrays.asList(new String[] {username}), 4)); this.markSaveDataDirty(); }
/** * This packet will notify the players that this team is created, and that will register it on the client */ public void broadcastTeamCreated(ScorePlayerTeam playerTeam) { super.broadcastTeamCreated(playerTeam); this.scoreboardMCServer.getPlayerList().sendPacketToAllPlayers(new SPacketTeams(playerTeam, 0)); this.markSaveDataDirty(); }
/** * This packet will notify the players that this team is updated */ public void broadcastTeamInfoUpdate(ScorePlayerTeam playerTeam) { super.broadcastTeamInfoUpdate(playerTeam); this.scoreboardMCServer.getPlayerList().sendPacketToAllPlayers(new SPacketTeams(playerTeam, 2)); this.markSaveDataDirty(); }
/** * Updates a team managed by the scoreboard: Create/Remove the team registration, Register/Remove the player-team- * memberships, Set team displayname/prefix/suffix and/or whether friendly fire is enabled */ public void handleTeams(SPacketTeams packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Scoreboard scoreboard = this.clientWorldController.getScoreboard(); ScorePlayerTeam scoreplayerteam; if (packetIn.getAction() == 0) { scoreplayerteam = scoreboard.createTeam(packetIn.getName()); } else { scoreplayerteam = scoreboard.getTeam(packetIn.getName()); } if (packetIn.getAction() == 0 || packetIn.getAction() == 2) { scoreplayerteam.setTeamName(packetIn.getDisplayName()); scoreplayerteam.setNamePrefix(packetIn.getPrefix()); scoreplayerteam.setNameSuffix(packetIn.getSuffix()); scoreplayerteam.setChatFormat(TextFormatting.fromColorIndex(packetIn.getColor())); scoreplayerteam.setFriendlyFlags(packetIn.getFriendlyFlags()); Team.EnumVisible team$enumvisible = Team.EnumVisible.getByName(packetIn.getNameTagVisibility()); if (team$enumvisible != null) { scoreplayerteam.setNameTagVisibility(team$enumvisible); } Team.CollisionRule team$collisionrule = Team.CollisionRule.getByName(packetIn.getCollisionRule()); if (team$collisionrule != null) { scoreplayerteam.setCollisionRule(team$collisionrule); } } if (packetIn.getAction() == 0 || packetIn.getAction() == 3) { for (String s : packetIn.getPlayers()) { scoreboard.addPlayerToTeam(s, packetIn.getName()); } } if (packetIn.getAction() == 4) { for (String s1 : packetIn.getPlayers()) { scoreboard.removePlayerFromTeam(s1, scoreplayerteam); } } if (packetIn.getAction() == 1) { scoreboard.removeTeam(scoreplayerteam); } }
public void broadcastTeamRemove(ScorePlayerTeam playerTeam) { super.broadcastTeamRemove(playerTeam); this.scoreboardMCServer.getPlayerList().sendPacketToAllPlayers(new SPacketTeams(playerTeam, 1)); this.markSaveDataDirty(); }
/** * Updates a team managed by the scoreboard: Create/Remove the team registration, Register/Remove the player-team- * memberships, Set team displayname/prefix/suffix and/or whether friendly fire is enabled */ void handleTeams(SPacketTeams packetIn);