use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class NbtScoreboardIoWriter method writeScores.
private static void writeScores(CompoundTag root, GlowScoreboard scoreboard) {
List<CompoundTag> scores = new ArrayList<>();
for (String objective : scoreboard.getEntries()) {
for (Score score : scoreboard.getScores(objective)) {
CompoundTag scoreNbt = new CompoundTag();
scoreNbt.putInt("Score", score.getScore());
scoreNbt.putString("Name", score.getEntry());
scoreNbt.putString("Objective", score.getObjective().getName());
scoreNbt.putByte("Locked", score.getLocked() ? 1 : 0);
scores.add(scoreNbt);
}
}
root.putCompoundList("PlayerScores", scores);
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class NbtScoreboardIoWriter method writeTeams.
private static void writeTeams(CompoundTag root, GlowScoreboard scoreboard) {
List<CompoundTag> teams = new ArrayList<>();
for (Team team : scoreboard.getTeams()) {
CompoundTag teamNbt = new CompoundTag();
teamNbt.putByte("AllowFriendlyFire", team.allowFriendlyFire() ? 1 : 0);
teamNbt.putByte("SeeFriendlyInvisibles", team.canSeeFriendlyInvisibles() ? 1 : 0);
teamNbt.putString("NameTagVisibility", team.getOption(Team.Option.NAME_TAG_VISIBILITY).name().toLowerCase());
switch(team.getOption(Team.Option.DEATH_MESSAGE_VISIBILITY)) {
case NEVER:
teamNbt.putString("DeathMessageVisibility", "never");
break;
case FOR_OTHER_TEAMS:
teamNbt.putString("DeathMessageVisibility", "hideForOtherTeams");
break;
case FOR_OWN_TEAM:
teamNbt.putString("DeathMessageVisibility", "hideForOwnTeam");
break;
default:
teamNbt.putString("DeathMessageVisibility", "always");
}
switch(team.getOption(Team.Option.COLLISION_RULE)) {
case NEVER:
teamNbt.putString("CollisionRule", "never");
break;
case FOR_OTHER_TEAMS:
teamNbt.putString("CollisionRule", "pushOtherTeams");
break;
case FOR_OWN_TEAM:
teamNbt.putString("CollisionRule", "pushOwnTeam");
break;
default:
teamNbt.putString("CollisionRule", "always");
}
teamNbt.putString("DisplayName", team.getDisplayName());
teamNbt.putString("Name", team.getName());
teamNbt.putString("Prefix", team.getPrefix());
teamNbt.putString("Suffix", team.getSuffix());
teamNbt.putString("TeamColor", team.getColor().name().toLowerCase());
List<String> players = team.getEntries().stream().collect(Collectors.toList());
teamNbt.putList("Players", TagType.STRING, players);
teams.add(teamNbt);
}
root.putCompoundList("Teams", teams);
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class NbtScoreboardIoWriter method writeDisplaySlots.
private static void writeDisplaySlots(CompoundTag root, GlowScoreboard scoreboard) {
CompoundTag slots = new CompoundTag();
if (scoreboard.getObjective(DisplaySlot.PLAYER_LIST) != null) {
slots.putString("slot_0", scoreboard.getObjective(DisplaySlot.PLAYER_LIST).getName());
}
if (scoreboard.getObjective(DisplaySlot.SIDEBAR) != null) {
slots.putString("slot_1", scoreboard.getObjective(DisplaySlot.SIDEBAR).getName());
}
if (scoreboard.getObjective(DisplaySlot.BELOW_NAME) != null) {
slots.putString("slot_2", scoreboard.getObjective(DisplaySlot.BELOW_NAME).getName());
}
root.putCompound("DisplaySlots", slots);
}
Aggregations