use of org.spongepowered.api.service.pagination.PaginationList.Builder in project modules-extra by CubeEngine.
the class Receiver method sendReports.
public void sendReports(List<ReportActions> reportActions) {
if (reportActions.isEmpty()) {
if (cmdSource instanceof Player) {
i18n.send(ChatTypes.ACTION_BAR, ((Player) cmdSource), NEGATIVE, "Nothing logged here");
return;
}
i18n.send(cmdSource, NEGATIVE, "Nothing logged here");
return;
}
cmdSource.sendMessage(Text.of(TextColors.GOLD, StringUtils.repeat("-", 53)));
for (ReportActions reportAction : reportActions) {
reportAction.showReport(this);
}
Builder builder = Sponge.getGame().getServiceManager().provideUnchecked(PaginationService.class).builder();
Text titleLineAmount = i18n.translate(cmdSource, POSITIVE, "Showing {amount} Logs", lines.size());
String titleLineSort = i18n.getTranslation(cmdSource, "(newest first)");
Text titleLine = Text.of(titleLineAmount, " ", TextColors.YELLOW, titleLineSort);
Text titleTimings = i18n.translate(cmdSource, NEUTRAL, "Query: {input#time} Report: {input#time}", TimeUtil.formatDuration(lookup.timing(Lookup.LookupTiming.LOOKUP)), TimeUtil.formatDuration(lookup.timing(Lookup.LookupTiming.REPORT)));
titleLine = titleLine.toBuilder().onHover(TextActions.showText(titleTimings)).build();
builder.title(titleLine).padding(Text.of("-")).contents(lines).linesPerPage(2 + Math.min(lines.size(), 18)).sendTo(cmdSource);
// TODO remove linesPerPage when Sponge puts the lines to the bottom
}
Aggregations