Search in sources :

Example 1 with Scoreboard

use of net.minecraft.server.v1_12_R1.Scoreboard in project PaperDev by Kamillaova.

the class CraftObjective method getDisplaySlot.

public DisplaySlot getDisplaySlot() throws IllegalStateException {
    CraftScoreboard scoreboard = checkState();
    Scoreboard board = scoreboard.board;
    ScoreboardObjective objective = this.objective;
    for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) {
        if (board.getObjectiveForSlot(i) == objective) {
            return CraftScoreboardTranslations.toBukkitSlot(i);
        }
    }
    return null;
}
Also used : Scoreboard(net.minecraft.server.v1_12_R1.Scoreboard) ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective)

Example 2 with Scoreboard

use of net.minecraft.server.v1_12_R1.Scoreboard in project PaperDev by Kamillaova.

the class CraftObjective method setDisplaySlot.

public void setDisplaySlot(DisplaySlot slot) throws IllegalStateException {
    CraftScoreboard scoreboard = checkState();
    Scoreboard board = scoreboard.board;
    ScoreboardObjective objective = this.objective;
    for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) {
        if (board.getObjectiveForSlot(i) == objective) {
            board.setDisplaySlot(i, null);
        }
    }
    if (slot != null) {
        int slotNumber = CraftScoreboardTranslations.fromBukkitSlot(slot);
        board.setDisplaySlot(slotNumber, getHandle());
    }
}
Also used : Scoreboard(net.minecraft.server.v1_12_R1.Scoreboard) ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective)

Example 3 with Scoreboard

use of net.minecraft.server.v1_12_R1.Scoreboard in project PaperDev by Kamillaova.

the class CraftScore method getScore.

public int getScore() throws IllegalStateException {
    Scoreboard board = objective.checkState().board;
    if (board.getPlayers().contains(entry)) {
        // Lazy
        Map<ScoreboardObjective, ScoreboardScore> scores = board.getPlayerObjectives(entry);
        ScoreboardScore score = scores.get(objective.getHandle());
        if (score != null) {
            // Lazy
            return score.getScore();
        }
    }
    // Lazy
    return 0;
}
Also used : Scoreboard(net.minecraft.server.v1_12_R1.Scoreboard) ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective) ScoreboardScore(net.minecraft.server.v1_12_R1.ScoreboardScore)

Example 4 with Scoreboard

use of net.minecraft.server.v1_12_R1.Scoreboard in project PaperDev by Kamillaova.

the class CraftScoreboardManager method setPlayerBoard.

// CraftBukkit method
public void setPlayerBoard(CraftPlayer player, org.bukkit.scoreboard.Scoreboard bukkitScoreboard) throws IllegalArgumentException {
    Validate.isTrue(bukkitScoreboard instanceof CraftScoreboard, "Cannot set player scoreboard to an unregistered Scoreboard");
    CraftScoreboard scoreboard = (CraftScoreboard) bukkitScoreboard;
    net.minecraft.server.v1_12_R1.Scoreboard oldboard = getPlayerBoard(player).getHandle();
    net.minecraft.server.v1_12_R1.Scoreboard newboard = scoreboard.getHandle();
    EntityPlayer entityplayer = player.getHandle();
    if (oldboard == newboard) {
        return;
    }
    if (scoreboard == mainScoreboard) {
        playerBoards.remove(player);
    } else {
        playerBoards.put(player, (CraftScoreboard) scoreboard);
    }
    // Old objective tracking
    HashSet<ScoreboardObjective> removed = new HashSet<ScoreboardObjective>();
    for (int i = 0; i < 3; ++i) {
        ScoreboardObjective scoreboardobjective = oldboard.getObjectiveForSlot(i);
        if (scoreboardobjective != null && !removed.contains(scoreboardobjective)) {
            entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1));
            removed.add(scoreboardobjective);
        }
    }
    // Old team tracking
    Iterator<?> iterator = oldboard.getTeams().iterator();
    while (iterator.hasNext()) {
        ScoreboardTeam scoreboardteam = (ScoreboardTeam) iterator.next();
        entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardTeam(scoreboardteam, 1));
    }
    // The above is the reverse of the below method.
    server.getPlayerList().sendScoreboard((ScoreboardServer) newboard, player.getHandle());
}
Also used : ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective) PacketPlayOutScoreboardObjective(net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardObjective) Scoreboard(net.minecraft.server.v1_12_R1.Scoreboard) PacketPlayOutScoreboardTeam(net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardTeam) PacketPlayOutScoreboardObjective(net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardObjective) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) HashSet(java.util.HashSet) ScoreboardTeam(net.minecraft.server.v1_12_R1.ScoreboardTeam) PacketPlayOutScoreboardTeam(net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardTeam)

Example 5 with Scoreboard

use of net.minecraft.server.v1_12_R1.Scoreboard in project PaperDev by Kamillaova.

the class CraftScoreboardManager method getNewScoreboard.

public CraftScoreboard getNewScoreboard() {
    // Spigot
    org.spigotmc.AsyncCatcher.catchOp("scoreboard creation");
    CraftScoreboard scoreboard = new CraftScoreboard(new ScoreboardServer(server));
    scoreboards.add(scoreboard);
    return scoreboard;
}
Also used : ScoreboardServer(net.minecraft.server.v1_12_R1.ScoreboardServer)

Aggregations

Scoreboard (net.minecraft.server.v1_12_R1.Scoreboard)4 ScoreboardObjective (net.minecraft.server.v1_12_R1.ScoreboardObjective)4 HashSet (java.util.HashSet)1 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)1 PacketPlayOutScoreboardObjective (net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardObjective)1 PacketPlayOutScoreboardTeam (net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardTeam)1 ScoreboardScore (net.minecraft.server.v1_12_R1.ScoreboardScore)1 ScoreboardServer (net.minecraft.server.v1_12_R1.ScoreboardServer)1 ScoreboardTeam (net.minecraft.server.v1_12_R1.ScoreboardTeam)1