Search in sources :

Example 1 with Builder

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
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) ReportActions(org.cubeengine.module.vigil.report.ReportActions) Builder(org.spongepowered.api.service.pagination.PaginationList.Builder) TextActions.showText(org.spongepowered.api.text.action.TextActions.showText) Text(org.spongepowered.api.text.Text) PaginationService(org.spongepowered.api.service.pagination.PaginationService)

Aggregations

ReportActions (org.cubeengine.module.vigil.report.ReportActions)1 Player (org.spongepowered.api.entity.living.player.Player)1 Builder (org.spongepowered.api.service.pagination.PaginationList.Builder)1 PaginationService (org.spongepowered.api.service.pagination.PaginationService)1 Text (org.spongepowered.api.text.Text)1 TextActions.showText (org.spongepowered.api.text.action.TextActions.showText)1