Search in sources :

Example 6 with PlayerTeam

use of net.minecraft.world.scores.PlayerTeam in project SpongeCommon by SpongePowered.

the class SpongeTeamBuilder method build.

@Override
public Team build() throws IllegalStateException {
    checkState(this.name != null, "Name cannot be null!");
    checkState(this.displayName != null, "DisplayName cannot be null!");
    final Team team = (Team) new PlayerTeam(null, this.name);
    team.setDisplayName(this.displayName);
    team.setColor(this.color);
    team.setPrefix(this.prefix);
    team.setSuffix(this.suffix);
    team.setAllowFriendlyFire(this.allowFriendlyFire);
    team.setCanSeeFriendlyInvisibles(this.showFriendlyInvisibles);
    team.setNameTagVisibility(this.nameTagVisibility.get());
    team.setDeathMessageVisibility(this.deathMessageVisibility.get());
    team.setCollisionRule(this.collisionRule.get());
    for (final Component member : this.members) {
        team.addMember(member);
    }
    return team;
}
Also used : PlayerTeam(net.minecraft.world.scores.PlayerTeam) PlayerTeam(net.minecraft.world.scores.PlayerTeam) Team(org.spongepowered.api.scoreboard.Team) Component(net.kyori.adventure.text.Component)

Example 7 with PlayerTeam

use of net.minecraft.world.scores.PlayerTeam in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method generateNoCollideTeam.

@Override
public void generateNoCollideTeam(Player player, UUID noCollide) {
    removeNoCollideTeam(player, noCollide);
    PlayerTeam team = new PlayerTeam(SidebarImpl.dummyScoreboard, Utilities.generateRandomColors(8));
    team.getPlayers().add(noCollide.toString());
    team.setCollisionRule(Team.CollisionRule.NEVER);
    HashMap<UUID, PlayerTeam> map = noCollideTeamMap.computeIfAbsent(player.getUniqueId(), k -> new HashMap<>());
    map.put(noCollide, team);
    send(player, ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true));
}
Also used : PlayerTeam(net.minecraft.world.scores.PlayerTeam)

Example 8 with PlayerTeam

use of net.minecraft.world.scores.PlayerTeam in project Denizen-For-Bukkit by DenizenScript.

the class SidebarImpl method remove.

@Override
public void remove() {
    for (PlayerTeam team : generatedTeams) {
        PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createRemovePacket(team));
    }
    generatedTeams.clear();
    PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj2, 1));
}
Also used : PlayerTeam(net.minecraft.world.scores.PlayerTeam) ClientboundSetObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetObjectivePacket)

Example 9 with PlayerTeam

use of net.minecraft.world.scores.PlayerTeam in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method removeNoCollideTeam.

@Override
public void removeNoCollideTeam(Player player, UUID noCollide) {
    if (noCollide == null || !player.isOnline()) {
        noCollideTeamMap.remove(player.getUniqueId());
        return;
    }
    HashMap<UUID, PlayerTeam> map = noCollideTeamMap.get(player.getUniqueId());
    if (map == null) {
        return;
    }
    PlayerTeam team = map.remove(noCollide);
    if (team != null) {
        send(player, ClientboundSetPlayerTeamPacket.createRemovePacket(team));
    }
    if (map.isEmpty()) {
        noCollideTeamMap.remove(player.getUniqueId());
    }
}
Also used : PlayerTeam(net.minecraft.world.scores.PlayerTeam)

Example 10 with PlayerTeam

use of net.minecraft.world.scores.PlayerTeam in project Denizen-For-Bukkit by DenizenScript.

the class SidebarImpl method remove.

@Override
public void remove() {
    for (PlayerTeam team : generatedTeams) {
        PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createRemovePacket(team));
    }
    generatedTeams.clear();
    PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj2, 1));
}
Also used : PlayerTeam(net.minecraft.world.scores.PlayerTeam) ClientboundSetObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetObjectivePacket)

Aggregations

PlayerTeam (net.minecraft.world.scores.PlayerTeam)11 ClientboundSetObjectivePacket (net.minecraft.network.protocol.game.ClientboundSetObjectivePacket)5 ClientboundSetDisplayObjectivePacket (net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket)3 ClientboundSetScorePacket (net.minecraft.network.protocol.game.ClientboundSetScorePacket)3 Objective (net.minecraft.world.scores.Objective)2 Component (net.kyori.adventure.text.Component)1 ClientboundSetPlayerTeamPacket (net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket)1 Score (net.minecraft.world.scores.Score)1 Team (org.spongepowered.api.scoreboard.Team)1 PlayerTeamAccessor (org.spongepowered.common.accessor.world.scores.PlayerTeamAccessor)1 SpongeScore (org.spongepowered.common.scoreboard.SpongeScore)1