From 84e1a7291bb4bcb54e36792a944a4e37c03ed0b7 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Wed, 28 Sep 2016 10:35:49 +0100 Subject: [PATCH] Report result gui should handle messaging of player invoking team assignment --- .../src/mineplex/core/report/ReportManager.java | 16 ++-------------- .../core/report/ui/ReportResultPage.java | 7 ++++++- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index ba3a5e96e..9a76424bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -25,12 +25,10 @@ import mineplex.core.chatsnap.command.PushSnapshotsHandler; import mineplex.core.command.CommandCenter; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilCollections; import mineplex.core.common.util.UtilFuture; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.incognito.IncognitoManager; import mineplex.core.portal.Portal; import mineplex.core.punish.Category; @@ -420,23 +418,13 @@ public class ReportManager * Assigns a team to a report. * * @param report the report to assign to a team - * @param player the player invoking this action * @param team the team to assign the report to * @return a future which completes once the database has been updated */ - public CompletableFuture assignTeam(Report report, Player player, ReportTeam team) + public CompletableFuture assignTeam(Report report, ReportTeam team) { report.setAssignedTeam(team); - CompletableFuture future = abortReport(report).thenCompose(voidValue -> saveReport(report)); - - if (player != null) - { - future.thenCompose(BukkitFuture.accept(reportId -> - UtilPlayer.message(player, - F.main(getReportPrefix(reportId), "Report forwarded to " + F.elem(team.name()) + " team")))); - } - - return future.thenApply(reportId -> null); // convert to Void + return abortReport(report).thenCompose(voidValue -> saveReport(report)).thenApply(reportId -> null); // convert to Void } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java index 01688530f..127f78114 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java @@ -3,6 +3,8 @@ package mineplex.core.report.ui; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.gui.SimpleGui; import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; @@ -60,7 +62,10 @@ public class ReportResultPage extends SimpleGui getPlayer().closeInventory(); unregisterListener(); - _reportManager.assignTeam(_report, getPlayer(), team); + _reportManager.assignTeam(_report, team).thenAccept(aVoid -> + UtilPlayer.message(getPlayer(), + F.main(ReportManager.getReportPrefix(_report), + "Report forwarded to " + F.elem(team.name()) + " team"))); } public void unregisterListener()