use of org.spongepowered.common.accessor.world.scores.PlayerTeamAccessor in project SpongeCommon by SpongePowered.
the class ServerScoreboardMixin method bridge$registerTeam.
// Add team
@Override
public void bridge$registerTeam(final Team spongeTeam) {
final PlayerTeam team = (PlayerTeam) spongeTeam;
if (this.getPlayerTeam(spongeTeam.name()) != null) {
throw new IllegalArgumentException(String.format("A team with the name '%s' already exists!", spongeTeam.name()));
}
if (((PlayerTeamAccessor) team).accessor$scoreboard() != null) {
throw new IllegalArgumentException("The passed in team is already registered to a scoreboard!");
}
((PlayerTeamAccessor) team).accessor$scoreboard(this);
((ScoreboardAccessor) this).accessor$teamsByName().put(team.getName(), team);
for (final String entry : team.getPlayers()) {
this.addPlayerToTeam(entry, team);
}
this.onTeamAdded(team);
}
Aggregations