use of com.ebicep.warlords.game.option.marker.scoreboard.ScoreboardHandler in project Warlords by ebicep.
the class PlayingState method updateBasedOnGameScoreboards.
private void updateBasedOnGameScoreboards(@Nonnull CustomScoreboard customScoreboard, @Nullable WarlordsPlayer warlordsPlayer) {
List<String> scoreboard = new ArrayList<>();
String lastGroup = null;
boolean lastWasEmpty = true;
for (ScoreboardHandler handler : Utils.iterable(game.getScoreboardHandlers().stream().sorted(Comparator.comparing((ScoreboardHandler sh) -> sh.getPriority(warlordsPlayer))))) {
String group = handler.getGroup();
if ((lastGroup == null || !lastGroup.equals(group)) && !lastWasEmpty) {
scoreboard.add("");
lastWasEmpty = true;
}
lastGroup = group;
List<String> handlerContents = handler.computeLines(warlordsPlayer);
if (!handlerContents.isEmpty()) {
lastWasEmpty = false;
scoreboard.addAll(handlerContents);
}
}
customScoreboard.giveNewSideBar(false, scoreboard);
}
Aggregations