use of org.spongepowered.common.bridge.server.ServerScoreboardBridge in project SpongeCommon by SpongePowered.
the class ServerScoreboardMixin method bridge$updateDisplaySlot.
@Override
public void bridge$updateDisplaySlot(@Nullable final Objective objective, final int slot) throws IllegalStateException {
if (objective != null && !objective.scoreboards().contains(this)) {
throw new IllegalStateException("Attempting to set an objective's display slot that does not exist on this scoreboard!");
}
((ScoreboardAccessor) this).accessor$displayObjectives()[slot] = objective == null ? null : ((SpongeObjective) objective).getObjectiveFor(this);
((ServerScoreboardBridge) this).bridge$sendToPlayers(new ClientboundSetDisplayObjectivePacket(slot, ((ScoreboardAccessor) this).accessor$displayObjectives()[slot]));
}
use of org.spongepowered.common.bridge.server.ServerScoreboardBridge in project SpongeCommon by SpongePowered.
the class ServerScoreboardMixin method bridge$removeObjective.
@Override
public void bridge$removeObjective(final Objective objective) {
final net.minecraft.world.scores.Objective scoreObjective = ((SpongeObjective) objective).getObjectiveFor(this);
((ScoreboardAccessor) this).accessor$objectivesByName().remove(scoreObjective.getName());
for (int i = 0; i < 19; ++i) {
if (this.getDisplayObjective(i) == scoreObjective) {
this.setDisplayObjective(i, null);
}
}
((ServerScoreboardBridge) this).bridge$sendToPlayers(new ClientboundSetObjectivePacket(scoreObjective, Constants.Scoreboards.OBJECTIVE_PACKET_REMOVE));
final List list = ((ScoreboardAccessor) this).accessor$objectivesByCriteria().get(scoreObjective.getCriteria());
if (list != null) {
list.remove(scoreObjective);
}
for (final Map<net.minecraft.world.scores.Objective, Score> scoreMap : ((ScoreboardAccessor) this).accessor$playerScores().values()) {
final Score score = scoreMap.remove(scoreObjective);
if (score != null) {
((ScoreBridge) score).bridge$getSpongeScore().removeScoreFor(scoreObjective);
}
}
this.shadow$setDirty();
((SpongeObjective) objective).removeObjectiveFor(this);
}
Aggregations