mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
try-catch for NPE in purge and fail gracefully if the world is null
Plausible scenario since purge is often run to remove plots in the DB from removed worlds Shouls fix #2806
This commit is contained in:
parent
4ad9f12d5d
commit
afe874a59b
@ -27,6 +27,7 @@ package com.plotsquared.core.command;
|
|||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
@ -192,16 +193,25 @@ public class Purge extends SubCommand {
|
|||||||
cleared.set(false);
|
cleared.set(false);
|
||||||
Plot plot = iterator.next();
|
Plot plot = iterator.next();
|
||||||
if (plot.temp != Integer.MAX_VALUE) {
|
if (plot.temp != Integer.MAX_VALUE) {
|
||||||
ids.add(plot.temp);
|
try {
|
||||||
if (finalClear) {
|
ids.add(plot.temp);
|
||||||
plot.clear(false, true, () -> PlotSquared
|
if (finalClear) {
|
||||||
.debug("Plot " + plot.getId() + " cleared by purge."));
|
plot.clear(false, true, () -> PlotSquared
|
||||||
} else {
|
.debug("Plot " + plot.getId() + " cleared by purge."));
|
||||||
plot.removeSign();
|
} else {
|
||||||
}
|
plot.removeSign();
|
||||||
plot.getArea().removePlot(plot.getId());
|
}
|
||||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
plot.getArea().removePlot(plot.getId());
|
||||||
PlotListener.plotEntry(pp, plot);
|
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||||
|
PlotListener.plotEntry(pp, plot);
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
PlotSquared.log(
|
||||||
|
"NullPointer during purge detected. This is likely because you are "
|
||||||
|
+ "deleting a world that has been removed.");
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cleared.set(true);
|
cleared.set(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user