use of net.glowstone.net.message.play.scoreboard.ScoreboardDisplayMessage 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);
}
use of net.glowstone.net.message.play.scoreboard.ScoreboardDisplayMessage in project Glowstone by GlowstoneMC.
the class GlowScoreboard method setDisplaySlot.
/**
* Set the objective displayed in the given slot.
*
* @param slot The display slot.
* @param objective The objective to display there, possibly null.
*/
void setDisplaySlot(DisplaySlot slot, GlowObjective objective) {
GlowObjective previous = displaySlots.put(slot, objective);
// previous objective is no longer in this display slot
if (previous != null) {
previous.displaySlot = null;
}
// new objective is now in this display slot
if (objective != null) {
// update objective's display slot
broadcast(new ScoreboardDisplayMessage(GlowDisplaySlot.getId(slot), objective.getName()));
objective.displaySlot = slot;
} else {
// no objective
broadcast(new ScoreboardDisplayMessage(GlowDisplaySlot.getId(slot), ""));
}
}
Aggregations