Fix /reporthandle command
This commit is contained in:
parent
d178e9112b
commit
871bb04451
@ -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<ReportPlugin>
|
||||
{
|
||||
ReportManager reportManager = Plugin.getReportManager();
|
||||
ReportRepository reportRepository = reportManager.getReportRepository();
|
||||
Map<Report, Double> reportPriorities = new ConcurrentHashMap<>();
|
||||
Map<Report, Double> 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<Report, Double> mostImportant = null;
|
||||
|
Loading…
Reference in New Issue
Block a user