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
1 changed files with 24 additions and 17 deletions

View File

@ -39,7 +39,10 @@ public class ReportStatsCommand extends CommandBase<ReportPlugin>
int accountId = accountIdOptional.get();
Plugin.getReportManager().getReportRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats ->
stats.keySet().forEach(role ->
{
UtilPlayer.message(player, F.main(Plugin.getName(), "Report Statistics for " + F.elem(playerName)));
for (ReportRole role : ReportRole.values())
{
long[] idArray = stats.get(role).stream()
.sorted((l1, l2) -> Longs.compare(l2, l1))
@ -47,15 +50,14 @@ public class ReportStatsCommand extends CommandBase<ReportPlugin>
.toArray();
int reportCount = idArray.length;
// don't show handler statistics if user has never handled a report
if (role != ReportRole.HANDLER || reportCount > 0)
{
// create clickable report ids
ChildJsonMessage jsonMessage = new JsonMessage(F.main(Plugin.getName(), ""))
.extra(C.mElem);
int displayAmount = Math.min(idArray.length, 5);
if (displayAmount > 0)
{
for (int i = 0; i < displayAmount; i++)
{
long reportId = idArray[i];
@ -68,11 +70,16 @@ public class ReportStatsCommand extends CommandBase<ReportPlugin>
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