use of com.skelril.skree.service.internal.highscore.ScoreType in project Skree by Skelril.
the class HighScoreCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
HighScoreService service = Sponge.getServiceManager().provideUnchecked(HighScoreService.class);
PaginationService pagination = Sponge.getServiceManager().provideUnchecked(PaginationService.class);
Optional<ScoreType> optScoreType = args.getOne("score type");
if (optScoreType.isPresent()) {
ScoreType scoreType = optScoreType.get();
List<Clause<Optional<GameProfile>, Integer>> scores = service.getTop(scoreType);
List<Text> result = new ArrayList<>(scores.size());
for (int i = 0; i < scores.size(); ++i) {
result.add(createScoreLine(i + 1, scores.get(i), scoreType));
}
pagination.builder().contents(result).title(Text.of(TextColors.GOLD, getFriendlyName(reverseChoices.get(scoreType)))).padding(Text.of(" ")).sendTo(src);
} else {
List<Text> result = choices.keySet().stream().map(this::createScoreTypeLine).sorted().collect(Collectors.toList());
pagination.builder().contents(result).title(Text.of(TextColors.GOLD, "High Score Tables")).padding(Text.of(" ")).sendTo(src);
}
return CommandResult.success();
}
Aggregations