use of org.cubeengine.module.vigil.report.ReportActions in project modules-extra by CubeEngine.
the class QueryManager method prepareReports.
private List<ReportActions> prepareReports(Lookup lookup, Player player, List<Action> results) {
lookup.time(Lookup.LookupTiming.REPORT);
List<ReportActions> reportActions = new ArrayList<>();
ReportActions last = null;
for (Action action : results) {
Report report = reportManager.reportOf(action);
if (last == null) {
last = new ReportActions(report);
reportActions.add(last);
}
if (!last.add(action, report, lookup)) {
last = new ReportActions(report);
reportActions.add(last);
last.add(action, report, lookup);
}
}
lookup.time(Lookup.LookupTiming.REPORT);
return reportActions;
}
use of org.cubeengine.module.vigil.report.ReportActions 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