From 03e219f552a8491dd56605666d454e612772dd92 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Thu, 13 Oct 2016 02:15:49 +0100 Subject: [PATCH] Add header to /reportstats and further improvements --- .../report/command/ReportStatsCommand.java | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java index 77619e680..e02de3ae1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java @@ -39,40 +39,47 @@ public class ReportStatsCommand extends CommandBase 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