Prevent double exception printing when an error occurs whilst saving
a report
This commit is contained in:
parent
26d6540b2f
commit
45eeac8cee
@ -266,64 +266,68 @@ public class ReportManager
|
||||
|
||||
saveCompletableFuture.thenAccept(reportId ->
|
||||
{
|
||||
if (reportResult.getType() == ReportResultType.ABUSIVE)
|
||||
try
|
||||
{
|
||||
// if report was marked abusive, check if each of the reporters
|
||||
// should be banned from using the report system
|
||||
report.getReporterIds().forEach(reporterId ->
|
||||
_reportRepository.getAccountUUID(reporterId).thenAccept(reporterUUID ->
|
||||
{
|
||||
CoreClient reporterClient = _clientManager.Get(reporterUUID);
|
||||
checkAbuseBan(reporterClient, reportCloser, reportId);
|
||||
}));
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(_plugin, () ->
|
||||
{
|
||||
String prefix = getReportPrefix(reportId);
|
||||
String reason = reportResult.getReason().orElse("No reason specified.");
|
||||
|
||||
if (reportCloser != null)
|
||||
if (reportResult.getType() == ReportResultType.ABUSIVE)
|
||||
{
|
||||
if (reportResult.getType() == ReportResultType.ACCEPTED)
|
||||
{
|
||||
// TODO: force moderator to choose a punishment (requires new punish gui)
|
||||
CommandCenter.Instance.onPlayerCommandPreprocess(
|
||||
new PlayerCommandPreprocessEvent(reportCloser,
|
||||
String.format("/punish %s Report #%s - %s", suspectName, reportId, reason)));
|
||||
}
|
||||
|
||||
// TODO: send these after punishment has been decided (requires new punish gui)
|
||||
reportCloser.sendMessage(
|
||||
F.main(prefix, "Report marked as: "
|
||||
+ C.cGold + reportResult.getType().getName()));
|
||||
reportCloser.sendMessage(F.main(prefix, "Reason: " + F.elem(reason)));
|
||||
// if report was marked abusive, check if each of the reporters
|
||||
// should be banned from using the report system
|
||||
report.getReporterIds().forEach(reporterId ->
|
||||
_reportRepository.getAccountUUID(reporterId).thenAccept(reporterUUID ->
|
||||
{
|
||||
CoreClient reporterClient = _clientManager.Get(reporterUUID);
|
||||
checkAbuseBan(reporterClient, reportCloser, reportId);
|
||||
}));
|
||||
}
|
||||
|
||||
getUUIDs(report.getReporterIds()).thenAccept(ids ->
|
||||
Bukkit.getScheduler().runTask(_plugin, () ->
|
||||
{
|
||||
ReportResultType resultType = reportResult.getType();
|
||||
ChildJsonMessage jsonMessage = new JsonMessage(F.main(
|
||||
prefix,
|
||||
"Your report against " + F.elem(suspectName) + " was marked as " + F.elem(resultType.getName()) + "."))
|
||||
.extra("\n");
|
||||
String prefix = getReportPrefix(reportId);
|
||||
String reason = reportResult.getReason().orElse("No reason specified.");
|
||||
|
||||
if (resultType == ReportResultType.ABUSIVE)
|
||||
if (reportCloser != null)
|
||||
{
|
||||
jsonMessage = jsonMessage.add(F.main(prefix, C.cRed + "Submitting false reports may result in punishment."))
|
||||
.add("\n");
|
||||
if (reportResult.getType() == ReportResultType.ACCEPTED)
|
||||
{
|
||||
// TODO: force moderator to choose a punishment (requires new punish gui)
|
||||
CommandCenter.Instance.onPlayerCommandPreprocess(
|
||||
new PlayerCommandPreprocessEvent(reportCloser,
|
||||
String.format("/punish %s Report #%s - %s", suspectName, reportId, reason)));
|
||||
}
|
||||
|
||||
// TODO: send these after punishment has been decided (requires new punish gui)
|
||||
reportCloser.sendMessage(
|
||||
F.main(prefix, "Report marked as: "
|
||||
+ C.cGold + reportResult.getType().getName()));
|
||||
reportCloser.sendMessage(F.main(prefix, "Reason: " + F.elem(reason)));
|
||||
}
|
||||
|
||||
jsonMessage = jsonMessage.add(F.main(prefix, "Reason: " + F.elem(reason)));
|
||||
getUUIDs(report.getReporterIds()).thenAccept(ids ->
|
||||
{
|
||||
ReportResultType resultType = reportResult.getType();
|
||||
ChildJsonMessage jsonMessage = new JsonMessage(F.main(
|
||||
prefix,
|
||||
"Your report against " + F.elem(suspectName) + " was marked as " + F.elem(resultType.getName()) + "."))
|
||||
.extra("\n");
|
||||
|
||||
new ReportersNotification(ids, jsonMessage).publish();
|
||||
if (resultType == ReportResultType.ABUSIVE)
|
||||
{
|
||||
jsonMessage = jsonMessage.add(F.main(prefix, C.cRed + "Submitting false reports may result in punishment."))
|
||||
.add("\n");
|
||||
}
|
||||
|
||||
jsonMessage = jsonMessage.add(F.main(prefix, "Reason: " + F.elem(reason)));
|
||||
|
||||
new ReportersNotification(ids, jsonMessage).publish();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
_reportRepository.clearCache(reportId);
|
||||
}).exceptionally(throwable -> {
|
||||
_plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable);
|
||||
return null;
|
||||
_reportRepository.clearCache(reportId);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
_plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user