Report result gui should handle messaging of player invoking team

assignment
This commit is contained in:
Keir Nellyer 2016-09-28 10:35:49 +01:00
parent e54f70d194
commit 84e1a7291b
2 changed files with 8 additions and 15 deletions

View File

@ -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<Void> assignTeam(Report report, Player player, ReportTeam team)
public CompletableFuture<Void> assignTeam(Report report, ReportTeam team)
{
report.setAssignedTeam(team);
CompletableFuture<Long> 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
}
/**

View File

@ -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()