use of org.spongepowered.common.bridge.world.scores.ObjectiveBridge in project SpongeCommon by SpongePowered.
the class ServerScoreboardMixin method resetPlayerScore.
@Override
public void resetPlayerScore(final String name, final net.minecraft.world.scores.Objective objective) {
final LegacyComponentSerializer lcs = LegacyComponentSerializer.legacySection();
if (objective != null) {
final SpongeObjective spongeObjective = ((ObjectiveBridge) objective).bridge$getSpongeObjective();
final Optional<org.spongepowered.api.scoreboard.Score> score = spongeObjective.findScore(lcs.deserialize(name));
if (score.isPresent()) {
spongeObjective.removeScore(score.get());
} else {
SpongeCommon.logger().warn("Objective {} did have have the score", name);
}
} else {
final Component textName = lcs.deserialize(name);
for (final net.minecraft.world.scores.Objective scoreObjective : this.getObjectives()) {
((ObjectiveBridge) scoreObjective).bridge$getSpongeObjective().removeScore(textName);
}
}
}
use of org.spongepowered.common.bridge.world.scores.ObjectiveBridge in project SpongeCommon by SpongePowered.
the class ServerScoreboardMixin_API method removeScores.
@Override
public void removeScores(final Component name) {
Objects.requireNonNull(name);
for (final net.minecraft.world.scores.Objective objective : ((ScoreboardAccessor) this).accessor$objectivesByName().values()) {
final SpongeObjective spongeObjective = ((ObjectiveBridge) objective).bridge$getSpongeObjective();
spongeObjective.findScore(name).ifPresent(spongeObjective::removeScore);
}
}
Aggregations