From a59bc8a19cab3e4d88d044cc140de805ced392d8 Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sat, 7 Apr 2018 11:17:09 +0100 Subject: [PATCH] Allow clicking on /reports list This will run /reports info on each report Part of #763 --- .../me/confuser/banmanager/util/CommandUtils.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/confuser/banmanager/util/CommandUtils.java b/src/main/java/me/confuser/banmanager/util/CommandUtils.java index d169ea7f..3f933d69 100644 --- a/src/main/java/me/confuser/banmanager/util/CommandUtils.java +++ b/src/main/java/me/confuser/banmanager/util/CommandUtils.java @@ -8,6 +8,7 @@ import me.confuser.banmanager.data.PlayerReportData; import me.confuser.banmanager.util.parsers.Reason; import me.confuser.bukkitutil.Message; +import me.rayzr522.jsonmessage.JSONMessage; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.FastDateFormat; import org.bukkit.Bukkit; @@ -202,7 +203,7 @@ public static void sendReportList(ReportList reports, CommandSender sender, int .sendTo(sender); for (PlayerReportData report : reports.getList()) { - Message.get("report.list.row.all") + String message = Message.get("report.list.row.all") .set("id", report.getId()) .set("state", report.getState().getName()) .set("player", report.getPlayer().getName()) @@ -211,8 +212,13 @@ public static void sendReportList(ReportList reports, CommandSender sender, int .set("created", dateFormatter .format(report.getCreated() * 1000L)) .set("updated", dateFormatter - .format(report.getUpdated() * 1000L)) - .sendTo(sender); + .format(report.getUpdated() * 1000L)).toString(); + + if (sender instanceof Player) { + JSONMessage.create(message).runCommand("/reports info " + report.getId()).send((Player) sender); + } else { + sender.sendMessage(message); + } } }