Search in sources :

Example 1 with PlayerTeamAccessor

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);
}
Also used : PlayerTeam(net.minecraft.world.scores.PlayerTeam) PlayerTeamAccessor(org.spongepowered.common.accessor.world.scores.PlayerTeamAccessor)

Aggregations

PlayerTeam (net.minecraft.world.scores.PlayerTeam)1 PlayerTeamAccessor (org.spongepowered.common.accessor.world.scores.PlayerTeamAccessor)1