From f2e88c1c54504c5d3368d5b7abaf4896ec493f5f Mon Sep 17 00:00:00 2001 From: Keir Date: Wed, 11 Nov 2015 19:05:29 +0000 Subject: [PATCH] Only allow 1 player at a time to handle a report. --- .../src/mineplex/core/report/Report.java | 5 +++++ .../mineplex/core/report/ReportManager.java | 22 +++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/Report.java b/Plugins/Mineplex.Core/src/mineplex/core/report/Report.java index dd20593ff..bfc4b3606 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/Report.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/Report.java @@ -2,6 +2,7 @@ package mineplex.core.report; import java.util.HashSet; import java.util.Set; +import java.util.UUID; import mineplex.serverdata.data.Data; @@ -22,6 +23,10 @@ public class Report implements Data public Set getReporters() { return _reporters; } public void addReporter(String reporter) { _reporters.add(reporter); } + private String _handler = null; + public void setHandler(String handler) { _handler = handler; } + public String getHandler() { return _handler; } + private Category _category; public Category getCategory() { return _category; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index c40793da5..1103fd05f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -9,6 +9,7 @@ import mineplex.core.command.CommandCenter; import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.report.command.ReportNotificationCallback; @@ -110,15 +111,22 @@ public class ReportManager { if (_reportRepository.elementExists(String.valueOf(reportId))) { Report report = getReport(reportId); - Portal.transferPlayer(reportHandler.getName(), report.getServerName()); - String handlerName = reportHandler.getName(); - sendReportNotification(String.format("[Report %d] %s is handling this report.", reportId, handlerName)); - // TODO: Send display message to handler when they arrive on the server - // with info about the case/report. + if (report.getPlayerName() != null) { + reportHandler.sendMessage(C.cRed + "Someone is already handling this report."); + } else { + String handlerName = reportHandler.getName(); + report.setHandler(handlerName); - int handlerId = getPlayerAccount(reportHandler).getAccountId(); - _reportSqlRepository.logReportHandling(reportId, handlerId); // Log handling into sql database + sendReportNotification(String.format("[Report %d] %s is handling this report.", reportId, handlerName)); + Portal.transferPlayer(reportHandler.getName(), report.getServerName()); + + // TODO: Send display message to handler when they arrive on the server + // with info about the case/report. + + int handlerId = getPlayerAccount(reportHandler).getAccountId(); + _reportSqlRepository.logReportHandling(reportId, handlerId); // Log handling into sql database + } } }