Search in sources :

Example 1 with IMixinScoreObjective

use of org.spongepowered.common.interfaces.IMixinScoreObjective in project SpongeCommon by SpongePowered.

the class MixinScoreboardLogic method scoreboard$removeScores.

public void scoreboard$removeScores(Text name) {
    for (ScoreObjective objective : this.scoreObjectives.values()) {
        SpongeObjective spongeObjective = ((IMixinScoreObjective) objective).getSpongeObjective();
        spongeObjective.getScore(name).ifPresent(spongeObjective::removeScore);
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) SpongeObjective(org.spongepowered.common.scoreboard.SpongeObjective)

Example 2 with IMixinScoreObjective

use of org.spongepowered.common.interfaces.IMixinScoreObjective in project SpongeCommon by SpongePowered.

the class MixinScoreboardLogic method removeObjectiveFromEntity.

@Override
public void removeObjectiveFromEntity(String name, ScoreObjective objective) {
    if (objective != null) {
        SpongeObjective spongeObjective = ((IMixinScoreObjective) objective).getSpongeObjective();
        Optional<org.spongepowered.api.scoreboard.Score> score = spongeObjective.getScore(SpongeTexts.fromLegacy(name));
        if (score.isPresent()) {
            spongeObjective.removeScore(score.get());
        } else {
            SpongeImpl.getLogger().warn("Objective " + objective + " did have have the score " + name);
        }
    } else {
        Text textName = SpongeTexts.fromLegacy(name);
        for (ScoreObjective scoreObjective : this.scoreObjectives.values()) {
            ((IMixinScoreObjective) scoreObjective).getSpongeObjective().removeScore(textName);
        }
    }
}
Also used : IMixinScore(org.spongepowered.common.interfaces.IMixinScore) Score(net.minecraft.scoreboard.Score) SpongeScore(org.spongepowered.common.scoreboard.SpongeScore) ScoreObjective(net.minecraft.scoreboard.ScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) SpongeObjective(org.spongepowered.common.scoreboard.SpongeObjective) Text(org.spongepowered.api.text.Text)

Example 3 with IMixinScoreObjective

use of org.spongepowered.common.interfaces.IMixinScoreObjective in project SpongeCommon by SpongePowered.

the class SpongeObjective method getObjectiveFor.

public ScoreObjective getObjectiveFor(net.minecraft.scoreboard.Scoreboard scoreboard) {
    if (this.objectives.containsKey(scoreboard)) {
        return this.objectives.get(scoreboard);
    }
    ScoreObjective objective = new ScoreObjective(scoreboard, this.name, (IScoreCriteria) this.criterion);
    // We deliberately set the fields here instead of using the methods.
    // Since a new objective is being created here, we want to avoid
    // sending packets until everything is in the proper state.
    objective.displayName = SpongeTexts.toLegacy(this.displayName);
    objective.renderType = (IScoreCriteria.EnumRenderType) (Object) this.displayMode;
    ((IMixinScoreObjective) objective).setSpongeObjective(this);
    this.objectives.put(scoreboard, objective);
    return objective;
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) IScoreCriteria(net.minecraft.scoreboard.IScoreCriteria)

Aggregations

ScoreObjective (net.minecraft.scoreboard.ScoreObjective)3 IMixinScoreObjective (org.spongepowered.common.interfaces.IMixinScoreObjective)3 SpongeObjective (org.spongepowered.common.scoreboard.SpongeObjective)2 IScoreCriteria (net.minecraft.scoreboard.IScoreCriteria)1 Score (net.minecraft.scoreboard.Score)1 Text (org.spongepowered.api.text.Text)1 IMixinScore (org.spongepowered.common.interfaces.IMixinScore)1 SpongeScore (org.spongepowered.common.scoreboard.SpongeScore)1