diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java index 0429a2c1a..1faee0da3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java @@ -1,8 +1,9 @@ package mineplex.core.report.command; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; @@ -32,17 +33,16 @@ public class ReportHandleCommand extends CommandBase { ReportManager reportManager = Plugin.getReportManager(); ReportRepository reportRepository = reportManager.getReportRepository(); - Map reportPriorities = new ConcurrentHashMap<>(); + Map reportPriorities = Collections.synchronizedMap(new HashMap<>()); // the below fetches the ids of all unhandled reports and gets a Report object for each of these ids // the priority of the report is then calculated and the results placed in a map - CompletableFuture.allOf( - reportRepository.getUnhandledReports().thenCompose(reportRepository::getReports).thenAccept(reports -> - reports.stream().map(report -> - reportManager.calculatePriority(report).thenAccept(priority -> - reportPriorities.put(report, priority) - ) - ).toArray(CompletableFuture[]::new)) + reportRepository.getUnhandledReports().thenCompose(reportRepository::getReports).thenAccept(reports -> + CompletableFuture.allOf(reports.stream().map(report -> + reportManager.calculatePriority(report).thenAccept(priority -> + reportPriorities.put(report, priority) + ) + ).toArray(CompletableFuture[]::new)).join() ).thenApply(aVoid -> { Map.Entry mostImportant = null;