Add header to /reportstats and further improvements

This commit is contained in:
Keir Nellyer 2016-10-13 02:15:49 +01:00
parent 2e16eef5d9
commit 03e219f552

View File

@ -39,40 +39,47 @@ public class ReportStatsCommand extends CommandBase<ReportPlugin>
int accountId = accountIdOptional.get();
Plugin.getReportManager().getReportRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats ->
stats.keySet().forEach(role ->
{
long[] idArray = stats.get(role).stream()
.sorted((l1, l2) -> Longs.compare(l2, l1))
.mapToLong(l -> l)
.toArray();
int reportCount = idArray.length;
UtilPlayer.message(player, F.main(Plugin.getName(), "Report Statistics for " + F.elem(playerName)));
// don't show handler statistics if user has never handled a report
if (role != ReportRole.HANDLER || reportCount > 0)
for (ReportRole role : ReportRole.values())
{
long[] idArray = stats.get(role).stream()
.sorted((l1, l2) -> Longs.compare(l2, l1))
.mapToLong(l -> l)
.toArray();
int reportCount = idArray.length;
// create clickable report ids
ChildJsonMessage jsonMessage = new JsonMessage(F.main(Plugin.getName(), ""))
.extra(C.mElem);
int displayAmount = Math.min(idArray.length, 5);
for (int i = 0; i < displayAmount; i++)
if (displayAmount > 0)
{
long reportId = idArray[i];
jsonMessage = jsonMessage.add(String.valueOf(reportId))
.click(ClickEvent.RUN_COMMAND, "/reportinfo " + reportId);
if (i != displayAmount - 1)
for (int i = 0; i < displayAmount; i++)
{
jsonMessage = jsonMessage.add(", ");
long reportId = idArray[i];
jsonMessage = jsonMessage.add(String.valueOf(reportId))
.click(ClickEvent.RUN_COMMAND, "/reportinfo " + reportId);
if (i != displayAmount - 1)
{
jsonMessage = jsonMessage.add(", ");
}
}
}
else
{
jsonMessage = jsonMessage.add("N/A");
}
UtilPlayer.message(player, F.main(Plugin.getName(), F.elem(role.getHumanName()) + " (" + reportCount + ")"));
jsonMessage.sendToPlayer(player);
}
})
}
));
}
else