Search in sources :

Example 6 with ScoreboardObjective

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

the class CraftScoreboard method registerNewObjective.

public CraftObjective registerNewObjective(String name, String criteria) throws IllegalArgumentException {
    Validate.notNull(name, "Objective name cannot be null");
    Validate.notNull(criteria, "Criteria cannot be null");
    Validate.isTrue(name.length() <= 16, "The name '" + name + "' is longer than the limit of 16 characters");
    Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists");
    CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
    ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria);
    return new CraftObjective(this, objective);
}
Also used : ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective)

Example 7 with ScoreboardObjective

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

the class CraftScoreboard method getObjectivesByCriteria.

public ImmutableSet<Objective> getObjectivesByCriteria(String criteria) throws IllegalArgumentException {
    Validate.notNull(criteria, "Criteria cannot be null");
    ImmutableSet.Builder<Objective> objectives = ImmutableSet.builder();
    for (ScoreboardObjective netObjective : (Collection<ScoreboardObjective>) this.board.getObjectives()) {
        CraftObjective objective = new CraftObjective(this, netObjective);
        if (objective.getCriteria().equals(criteria)) {
            objectives.add(objective);
        }
    }
    return objectives.build();
}
Also used : Objective(org.bukkit.scoreboard.Objective) ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective) ImmutableSet(com.google.common.collect.ImmutableSet) ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective) Collection(java.util.Collection)

Example 8 with ScoreboardObjective

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

the class CraftScoreboard method getObjective.

public Objective getObjective(String name) throws IllegalArgumentException {
    Validate.notNull(name, "Name cannot be null");
    ScoreboardObjective nms = board.getObjective(name);
    return nms == null ? null : new CraftObjective(this, nms);
}
Also used : ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective)

Example 9 with ScoreboardObjective

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

the class CraftScoreboard method getObjective.

public Objective getObjective(DisplaySlot slot) throws IllegalArgumentException {
    Validate.notNull(slot, "Display slot cannot be null");
    ScoreboardObjective objective = board.getObjectiveForSlot(CraftScoreboardTranslations.fromBukkitSlot(slot));
    if (objective == null) {
        return null;
    }
    return new CraftObjective(this, objective);
}
Also used : ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective)

Aggregations

ScoreboardObjective (net.minecraft.server.v1_12_R1.ScoreboardObjective)9 Scoreboard (net.minecraft.server.v1_12_R1.Scoreboard)4 ImmutableSet (com.google.common.collect.ImmutableSet)2 Collection (java.util.Collection)2 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 ScoreboardTeam (net.minecraft.server.v1_12_R1.ScoreboardTeam)1 Objective (org.bukkit.scoreboard.Objective)1 Score (org.bukkit.scoreboard.Score)1