No longer close reports when the player quits, instead alert the handler and alert again when (and if) the player re-joins if the report is still active.

This commit is contained in:
Keir 2015-11-17 15:08:35 +00:00
parent a1713ca866
commit 6ee40aa1ce
3 changed files with 42 additions and 16 deletions

View File

@ -97,7 +97,7 @@ public class ReportManager {
if (reportCloser != null)
{
// Notify staff that the report was closed.
sendReportNotification(
sendStaffNotification(
F.main(getReportPrefix(reportId), String.format("%s closed the report for: %s (%s).",
reportCloser.getName(), reason, result.toDisplayMessage() + C.mBody)));
@ -120,7 +120,7 @@ public class ReportManager {
report.setHandler(handlerName);
_reportRepository.addElement(report); // update existing value in Redis
sendReportNotification(F.main(getReportPrefix(reportId), String.format("%s is handling this report.", handlerName)));
sendStaffNotification(F.main(getReportPrefix(reportId), String.format("%s is handling this report.", handlerName)));
Portal.transferPlayer(reportHandler.getName(), report.getServerName());
// Show user details of the report every x seconds
@ -178,11 +178,11 @@ public class ReportManager {
message = message.extra("\n" + F.main(getReportPrefix(reportId), "Click to handle this ticket."))
.click(ClickEvent.RUN_COMMAND, "/reporthandle " + reportId);
sendReportNotification(message);
sendStaffNotification(message);
}
else
{
sendReportHandlerNotification(report, message);
sendHandlerNotification(report, message);
}
}
@ -193,13 +193,23 @@ public class ReportManager {
return null;
}
public void onPlayerJoin(Player player)
{
if (hasActiveReport(player))
{
int reportId = getActiveReport(player.getName());
Report report = getReport(reportId);
sendHandlerNotification(report, F.main(getReportPrefix(reportId), String.format("%s has re-joined the game.", player.getName())));
}
}
public void onPlayerQuit(Player player)
{
if (hasActiveReport(player))
{
int reportId = getActiveReport(player.getName());
this.closeReport(reportId, null, "Player Quit", ReportResult.UNDETERMINED);
sendReportNotification(F.main(getReportPrefix(reportId), String.format("%s has left the game.", player.getName())));
Report report = getReport(reportId);
sendHandlerNotification(report, F.main(getReportPrefix(reportId), String.format("%s has left the game.", player.getName())));
}
}
@ -287,7 +297,7 @@ public class ReportManager {
*
* @param message - the report notification message to send.
*/
public void sendReportNotification(JsonMessage message)
public void sendStaffNotification(JsonMessage message)
{
ReportNotification reportNotification = new ReportNotification(message);
reportNotification.publish();
@ -298,7 +308,7 @@ public class ReportManager {
*
* @param message - the report notification message to send.
*/
public void sendReportNotification(String message)
public void sendStaffNotification(String message)
{
ReportNotification reportNotification = new ReportNotification(message);
reportNotification.publish();
@ -306,26 +316,35 @@ public class ReportManager {
/**
* Send to the handler of a {@link Report}, regardless of whether or not the handler is currently on this server instance.
* If there is no handler for a report, it will be sent to all staff instead.
*
* @param report the report of which a message should be sent ot it's handler
* @param jsonMessage the report notification message to send
*/
public void sendReportHandlerNotification(Report report, JsonMessage jsonMessage)
public void sendHandlerNotification(Report report, JsonMessage jsonMessage)
{
ReportHandlerNotification reportNotification = new ReportHandlerNotification(report, jsonMessage);
reportNotification.publish();
if (report.getHandler() != null)
{
ReportHandlerNotification reportHandlerNotification = new ReportHandlerNotification(report, jsonMessage);
reportHandlerNotification.publish();
}
else
{
// If there is no report handler, send it to all staff
sendStaffNotification(jsonMessage);
}
}
/**
* Send to the handler of a {@link Report}, regardless of whether or not the handler is currently on this server instance.
* If there is no handler for a report, it will be sent to all staff instead.
*
* @param report the report of which a message should be sent ot it's handler
* @param message the report notification message to send
*/
public void sendReportHandlerNotification(Report report, String message)
public void sendHandlerNotification(Report report, String message)
{
ReportHandlerNotification reportNotification = new ReportHandlerNotification(report, message);
reportNotification.publish();
sendHandlerNotification(report, new JsonMessage(message));
}
/**
@ -343,6 +362,7 @@ public class ReportManager {
return -1;
}
// TODO this and related methods only function on the server where the report was created
public boolean hasActiveReport(Player player)
{
return getActiveReport(player.getName()) != -1;

View File

@ -6,6 +6,7 @@ import mineplex.core.report.command.ReportCommand;
import mineplex.core.report.command.ReportHandleCommand;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -34,6 +35,12 @@ public class ReportPlugin extends MiniPlugin
//AddCommand(new ReportDebugCommand(this));
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e)
{
_reportManager.onPlayerJoin(e.getPlayer());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e)
{

View File

@ -6,8 +6,7 @@ public enum ReportResult
{
ACCEPTED(ChatColor.GREEN, "Accept Report (Punish Player)", "Accepted (Player Received Punishment)"),
DENIED(ChatColor.YELLOW, "Deny Report", "Denied"),
ABUSIVE(ChatColor.RED, "Mark Abusive Report", "Abusive Report"),
UNDETERMINED(ChatColor.LIGHT_PURPLE, null, "Undetermined");
ABUSIVE(ChatColor.RED, "Mark Abusive Report", "Abusive Report");
private ChatColor _color;
private String _actionMessage;