/**
* Saves a scoreboard to a configuration file.
*
* @param config
* The configuration file.
* @param scoreboard
* The scoreboard.
*/
public void saveScoreboard(Configuration config, Scoreboard scoreboard) {
// Save teams
ConfigurationSection teamsSection = config.createSection("teams");
scoreboard.getTeams().forEach(team -> {
ConfigurationSection teamSection = teamsSection.createSection(team.getName());
saveTeam(teamSection, team);
});
// Save objectives
ConfigurationSection objectivesSection = config.createSection("objectives");
scoreboard.getObjectives().forEach(objective -> {
ConfigurationSection objectiveSection = objectivesSection.createSection(objective.getName());
objectiveSection.set("criteria", objective.getCriteria());
objectiveSection.set("display_name", objective.getDisplayName());
objectiveSection.set("display_slot", objective.getDisplaySlot().toString().toLowerCase());
});
// Save scores
ConfigurationSection scoresSection = config.createSection("scores");
scoreboard.getEntries().forEach(playerName -> {
ConfigurationSection playerSection = scoresSection.createSection(playerName);
scoreboard.getScores(playerName)
.forEach(score -> playerSection.set(score.getObjective().getName(), score.getScore()));
});
}
ScoreboardPersister.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:Pokkit
作者:
评论列表
文章目录