From 5bd53436dfcb274c6bd89a6dd3c0b6f92193358d Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Tue, 21 Apr 2020 15:50:47 +0200 Subject: [PATCH] Prevent NPE for report comments --- .../main/java/com/plotsquared/core/database/SQLManager.java | 5 +---- Core/src/main/java/com/plotsquared/core/plot/Plot.java | 2 +- .../java/com/plotsquared/core/plot/comment/InboxReport.java | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java index 64881c8a6..4ced85720 100644 --- a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java +++ b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java @@ -248,10 +248,7 @@ import java.util.concurrent.atomic.AtomicInteger; return this.notifyTasks; } - public synchronized void addPlotTask(Plot plot, UniqueStatement task) { - if (plot == null) { - plot = new Plot(null, new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE)); - } + public synchronized void addPlotTask(@NotNull Plot plot, UniqueStatement task) { Queue tasks = this.plotTasks.get(plot); if (tasks == null) { tasks = new ConcurrentLinkedQueue<>(); diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index a79b6fb7d..d029542dd 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -204,7 +204,7 @@ public class Plot { * @param id the plot id * @see Plot#getPlot(Location) for existing plots */ - public Plot(PlotArea area, @NotNull PlotId id) { + public Plot(@NotNull PlotArea area, @NotNull PlotId id) { this(area, id, null, 0); } diff --git a/Core/src/main/java/com/plotsquared/core/plot/comment/InboxReport.java b/Core/src/main/java/com/plotsquared/core/plot/comment/InboxReport.java index 3dc74b016..50aed9597 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/comment/InboxReport.java +++ b/Core/src/main/java/com/plotsquared/core/plot/comment/InboxReport.java @@ -35,7 +35,7 @@ import java.util.List; public class InboxReport extends CommentInbox { @Override public boolean getComments(Plot plot, final RunnableVal> whenDone) { - DBFunc.getComments(null, toString(), new RunnableVal>() { + DBFunc.getComments(plot, toString(), new RunnableVal>() { @Override public void run(List value) { whenDone.value = value; TaskManager.runTask(whenDone);