use of net.glowstone.net.message.play.scoreboard.ScoreboardScoreMessage in project Glowstone by GlowstoneMC.
the class GlowScore method setScore.
/**
* Sets this score's value.
* @param score the new value
* @throws IllegalStateException if the objective is not registered on a scoreboard
*/
@Override
public void setScore(int score) throws IllegalStateException {
objective.checkValid();
this.score = score;
objective.getScoreboard().broadcast(new ScoreboardScoreMessage(entry, objective.getName(), score));
}
use of net.glowstone.net.message.play.scoreboard.ScoreboardScoreMessage in project Glowstone by GlowstoneMC.
the class GlowScoreboard method subscribe.
// //////////////////////////////////////////////////////////////////////////
// Internals
/**
* Send a player this scoreboard's contents and subscribe them to future changes.
*
* @param player The player to subscribe.
*/
public void subscribe(GlowPlayer player) {
// objectives
for (GlowObjective objective : objectives.values()) {
player.getSession().send(ScoreboardObjectiveMessage.create(objective.getName(), new TextMessage(objective.getDisplayName())));
}
// display slots
for (DisplaySlot slot : DisplaySlot.values()) {
GlowObjective objective = displaySlots.get(slot);
String name = objective != null ? objective.getName() : "";
player.getSession().send(new ScoreboardDisplayMessage(GlowDisplaySlot.getId(slot), name));
}
// scores
for (Entry<String, Set<GlowScore>> entry : scoreMap.entrySet()) {
for (GlowScore score : entry.getValue()) {
player.getSession().send(new ScoreboardScoreMessage(entry.getKey(), score.getObjective().getName(), score.getScore()));
}
}
// teams
for (GlowTeam team : teams.values()) {
player.getSession().send(team.getCreateMessage());
}
// add to player set
players.add(player);
}
Aggregations