Search in sources :

Example 1 with ScoreboardHandler

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);
}
Also used : ScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.ScoreboardHandler) ArrayList(java.util.ArrayList)

Aggregations

ScoreboardHandler (com.ebicep.warlords.game.option.marker.scoreboard.ScoreboardHandler)1 ArrayList (java.util.ArrayList)1