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);
}
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
}
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);
}
Aggregations