From 976e8788b74eb43953860c3ad308173590ba4280 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Mon, 18 Jul 2016 18:37:21 +0100 Subject: [PATCH] Update report message if a player reports another player multiple times --- .../src/mineplex/core/common/util/UtilItem.java | 1 - .../src/mineplex/core/report/ReportManager.java | 17 ++++++++++++++--- .../src/mineplex/core/report/data/Report.java | 10 ++++++++++ .../core/report/data/ReportMessage.java | 5 +++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 29a4b76b8..eb936e763 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -1,7 +1,6 @@ package mineplex.core.common.util; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 0634e231c..85ec73657 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -82,10 +82,10 @@ public class ReportManager * @param reporter the player creating the report * @param suspect the player that is being reported * @param category the category of the report - * @param reason the reason this player reported the other + * @param message the reason this player reported the other * @return a future which when completed contains a {@link Report} instance of the report just created or added to */ - public CompletableFuture createReport(Player reporter, Player suspect, ReportCategory category, String reason) + public CompletableFuture createReport(Player reporter, Player suspect, ReportCategory category, String message) { int reporterId = _clientManager.Get(reporter).getAccountId(); int suspectId = _clientManager.Get(suspect).getAccountId(); @@ -97,7 +97,18 @@ public class ReportManager { if (report != null) { - report.addReportReason(new ReportMessage(reporterId, reason, _serverName, _serverWeight)); + ReportMessage reportMessage = report.getReportMessage(reporterId); + + if (reportMessage != null) + { + reportMessage.setMessage(message); + } + else + { + reportMessage = new ReportMessage(reporterId, message, _serverName, _serverWeight); + report.addReportReason(reportMessage); + } + saveReport(report).join(); } }); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java index 872002ddd..2793b5559 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java @@ -53,6 +53,16 @@ public class Report _reportMessages.put(reportMessage.getReporterId(), reportMessage); } + public Map getReportMessages() + { + return _reportMessages; + } + + public ReportMessage getReportMessage(int accountId) + { + return _reportMessages.get(accountId); + } + public Set getReporterIds() { return _reportMessages.keySet(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportMessage.java index d51c2bb28..9471e91a8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportMessage.java @@ -46,6 +46,11 @@ public class ReportMessage return _message; } + public void setMessage(String message) + { + _message = message; + } + public String getServer() { return _server;