Java 类net.minecraft.server.ScoreboardObjective 实例源码

项目:CraftBukkit    文件:CraftScoreboard.java   
CraftScoreboard(Scoreboard board) {
    this.board = board;

    for (ScoreboardObjective objective : (Iterable<ScoreboardObjective>) board.getObjectives()) {
        new CraftObjective(this, objective); // It adds itself to map
    }
    for (ScoreboardTeam team : (Iterable<ScoreboardTeam>) board.getTeams()) {
        new CraftTeam(this, team); // It adds itself to map
    }
}
项目:CraftBukkit    文件:CraftScoreboard.java   
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);
}
项目:CraftBukkit    文件:CraftScoreboard.java   
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 this.objectives.get(objective.getName());
}
项目:CraftBukkit    文件:CraftObjective.java   
CraftObjective(CraftScoreboard scoreboard, ScoreboardObjective objective) {
    super(scoreboard);
    this.objective = objective;
    this.criteria = CraftCriteria.getFromNMS(objective);

    scoreboard.objectives.put(objective.getName(), this);
}
项目:CraftBukkit    文件:CraftObjective.java   
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());
    }
}
项目:CraftBukkit    文件:CraftObjective.java   
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;
}
项目:CraftBukkit    文件:CraftScoreboardManager.java   
public Collection<ScoreboardScore> getScoreboardScores(IScoreboardCriteria criteria, String name, Collection<ScoreboardScore> collection) {
    for (CraftScoreboard scoreboard : scoreboards) {
        Scoreboard board = scoreboard.board;
        for (ScoreboardObjective objective : (Iterable<ScoreboardObjective>) board.getObjectivesForCriteria(criteria)) {
            collection.add(board.getPlayerScoreForObjective(name, objective));
        }
    }
    return collection;
}
项目:Craftbukkit    文件:CraftScore.java   
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();
        }
    }

    return 0; // Lazy
}
项目:Craftbukkit    文件:CraftScoreboard.java   
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);
}
项目:Craftbukkit    文件:CraftScoreboard.java   
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();
}
项目:Craftbukkit    文件:CraftScoreboard.java   
public ImmutableSet<Objective> getObjectives() {
    return ImmutableSet.copyOf(Iterables.transform((Collection<ScoreboardObjective>) this.board.getObjectives(), new Function<ScoreboardObjective, Objective>() {

        @Override
        public Objective apply(ScoreboardObjective input) {
            return new CraftObjective(CraftScoreboard.this, input);
        }
    }));
}
项目:Craftbukkit    文件:CraftScoreboard.java   
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);
}
项目:Craftbukkit    文件:CraftScoreboard.java   
public ImmutableSet<Score> getScores(String entry) throws IllegalArgumentException {
    Validate.notNull(entry, "Entry cannot be null");

    ImmutableSet.Builder<Score> scores = ImmutableSet.builder();
    for (ScoreboardObjective objective : (Collection<ScoreboardObjective>) this.board.getObjectives()) {
        scores.add(new CraftScore(new CraftObjective(this, objective), entry));
    }
    return scores.build();
}
项目:Craftbukkit    文件:CraftScoreboard.java   
public void resetScores(String entry) throws IllegalArgumentException {
    Validate.notNull(entry, "Entry cannot be null");

    for (ScoreboardObjective objective : (Collection<ScoreboardObjective>) this.board.getObjectives()) {
        board.resetPlayerScores(entry, objective);
    }
}
项目:Craftbukkit    文件:CraftObjective.java   
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());
    }
}
项目:Craftbukkit    文件:CraftObjective.java   
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;
}
项目:Craftbukkit    文件:CraftScoreboardManager.java   
public Collection<ScoreboardScore> getScoreboardScores(IScoreboardCriteria criteria, String name, Collection<ScoreboardScore> collection) {
    for (CraftScoreboard scoreboard : scoreboards) {
        Scoreboard board = scoreboard.board;
        for (ScoreboardObjective objective : (Iterable<ScoreboardObjective>) board.getObjectivesForCriteria(criteria)) {
            collection.add(board.getPlayerScoreForObjective(name, objective));
        }
    }
    return collection;
}
项目:Almura-Server    文件:CraftScore.java   
public void reset() throws IllegalStateException {
    CraftScoreboard myBoard = objective.checkState();
    Map<ScoreboardObjective, ScoreboardScore> savedScores = myBoard.board.getPlayerObjectives(playerName);
    if (savedScores.remove(objective.getHandle()) == null) {
        // If they don't have a score to delete, don't delete it.
        return;
    }
    myBoard.board.resetPlayerScores(playerName);
    for (Map.Entry<ScoreboardObjective, ScoreboardScore> e : savedScores.entrySet()) {
        myBoard.board.getPlayerScoreForObjective(playerName, e.getKey()).setScore(e.getValue().getScore());
    }
}
项目:Almura-Server    文件:CraftScoreboard.java   
CraftScoreboard(Scoreboard board) {
    this.board = board;

    for (ScoreboardObjective objective : (Iterable<ScoreboardObjective>) board.getObjectives()) {
        new CraftObjective(this, objective); // It adds itself to map
    }
    for (ScoreboardTeam team : (Iterable<ScoreboardTeam>) board.getTeams()) {
        new CraftTeam(this, team); // It adds itself to map
    }
}
项目:Almura-Server    文件:CraftScoreboard.java   
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);
}
项目:Almura-Server    文件:CraftScoreboard.java   
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 this.objectives.get(objective.getName());
}
项目:Almura-Server    文件:CraftObjective.java   
CraftObjective(CraftScoreboard scoreboard, ScoreboardObjective objective) {
    super(scoreboard);
    this.objective = objective;
    this.criteria = CraftCriteria.getFromNMS(objective);

    scoreboard.objectives.put(objective.getName(), this);
}
项目:Almura-Server    文件:CraftObjective.java   
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());
    }
}
项目:Almura-Server    文件:CraftObjective.java   
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;
}
项目:Almura-Server    文件:CraftScoreboardManager.java   
public Collection<ScoreboardScore> getScoreboardScores(IScoreboardCriteria criteria, String name, Collection<ScoreboardScore> collection) {
    for (CraftScoreboard scoreboard : scoreboards) {
        Scoreboard board = scoreboard.board;
        for (ScoreboardObjective objective : (Iterable<ScoreboardObjective>) board.getObjectivesForCriteria(criteria)) {
            collection.add(board.getPlayerScoreForObjective(name, objective));
        }
    }
    return collection;
}
项目:Tweakkit-Server    文件:CraftScoreboard.java   
CraftScoreboard(Scoreboard board) {
    this.board = board;

    for (ScoreboardObjective objective : (Iterable<ScoreboardObjective>) board.getObjectives()) {
        new CraftObjective(this, objective); // It adds itself to map
    }
    for (ScoreboardTeam team : (Iterable<ScoreboardTeam>) board.getTeams()) {
        new CraftTeam(this, team); // It adds itself to map
    }
}
项目:Tweakkit-Server    文件:CraftScoreboard.java   
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);
}
项目:Tweakkit-Server    文件:CraftScoreboard.java   
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 this.objectives.get(objective.getName());
}
项目:Tweakkit-Server    文件:CraftObjective.java   
CraftObjective(CraftScoreboard scoreboard, ScoreboardObjective objective) {
    super(scoreboard);
    this.objective = objective;
    this.criteria = CraftCriteria.getFromNMS(objective);

    scoreboard.objectives.put(objective.getName(), this);
}
项目:Tweakkit-Server    文件:CraftObjective.java   
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());
    }
}
项目:Tweakkit-Server    文件:CraftObjective.java   
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;
}
项目:Tweakkit-Server    文件:CraftScoreboardManager.java   
public Collection<ScoreboardScore> getScoreboardScores(IScoreboardCriteria criteria, String name, Collection<ScoreboardScore> collection) {
    for (CraftScoreboard scoreboard : scoreboards) {
        Scoreboard board = scoreboard.board;
        for (ScoreboardObjective objective : (Iterable<ScoreboardObjective>) board.getObjectivesForCriteria(criteria)) {
            collection.add(board.getPlayerScoreForObjective(name, objective));
        }
    }
    return collection;
}
项目:SpigotSource    文件:CraftScore.java   
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();
        }
    }

    return 0; // Lazy
}
项目:SpigotSource    文件:CraftScoreboard.java   
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);
}
项目:SpigotSource    文件:CraftScoreboard.java   
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();
}
项目:SpigotSource    文件:CraftScoreboard.java   
public ImmutableSet<Objective> getObjectives() {
    return ImmutableSet.copyOf(Iterables.transform((Collection<ScoreboardObjective>) this.board.getObjectives(), new Function<ScoreboardObjective, Objective>() {

        @Override
        public Objective apply(ScoreboardObjective input) {
            return new CraftObjective(CraftScoreboard.this, input);
        }
    }));
}
项目:SpigotSource    文件:CraftScoreboard.java   
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);
}
项目:SpigotSource    文件:CraftScoreboard.java   
public ImmutableSet<Score> getScores(String entry) throws IllegalArgumentException {
    Validate.notNull(entry, "Entry cannot be null");

    ImmutableSet.Builder<Score> scores = ImmutableSet.builder();
    for (ScoreboardObjective objective : (Collection<ScoreboardObjective>) this.board.getObjectives()) {
        scores.add(new CraftScore(new CraftObjective(this, objective), entry));
    }
    return scores.build();
}
项目:SpigotSource    文件:CraftScoreboard.java   
public void resetScores(String entry) throws IllegalArgumentException {
    Validate.notNull(entry, "Entry cannot be null");

    for (ScoreboardObjective objective : (Collection<ScoreboardObjective>) this.board.getObjectives()) {
        board.resetPlayerScores(entry, objective);
    }
}
项目:SpigotSource    文件:CraftObjective.java   
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());
    }
}