Search in sources :

Example 1 with TextActions.showText

use of org.spongepowered.api.text.action.TextActions.showText in project modules-extra by CubeEngine.

the class Receiver method sendReport.

public void sendReport(Report report, List<Action> actions, int size, String msgSingular, String msgPlural, Object... args) {
    Text trans = i18n.translateN(cmdSource, NEUTRAL, size, msgSingular, msgPlural, args).toBuilder().onHover(TextActions.showText(Text.of(report.getClass().getSimpleName()))).build();
    sendReport(actions, trans);
}
Also used : TextActions.showText(org.spongepowered.api.text.action.TextActions.showText) Text(org.spongepowered.api.text.Text)

Example 2 with TextActions.showText

use of org.spongepowered.api.text.action.TextActions.showText 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)

Example 3 with TextActions.showText

use of org.spongepowered.api.text.action.TextActions.showText in project modules-extra by CubeEngine.

the class Receiver method sendReport.

// TODO translate msgs on this method
public void sendReport(Report report, List<Action> actions, String msg, Object... args) {
    Text trans = i18n.translate(cmdSource, NEUTRAL, msg, args).toBuilder().onHover(TextActions.showText(Text.of(report.getClass().getSimpleName()))).build();
    sendReport(actions, trans);
}
Also used : TextActions.showText(org.spongepowered.api.text.action.TextActions.showText) Text(org.spongepowered.api.text.Text)

Aggregations

Text (org.spongepowered.api.text.Text)3 TextActions.showText (org.spongepowered.api.text.action.TextActions.showText)3 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