Check if location has PlotArea to avoid NPE

This commit is contained in:
Alexander Krivács Schrøder 2019-05-31 21:16:29 +02:00 committed by Matt
parent d106262454
commit a94c588a17

View File

@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -16,13 +17,17 @@ public class DebugRoadRegen extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) {
Location loc = player.getLocation();
PlotManager manager = loc.getPlotArea().getPlotManager();
PlotArea area = loc.getPlotArea();
if (area == null) {
return sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
}
Plot plot = player.getCurrentPlot();
if (plot == null) {
Captions.NOT_IN_PLOT.send(player);
} else if (plot.isMerged()) {
Captions.REQUIRES_UNMERGED.send(player);
} else {
PlotManager manager = area.getPlotManager();
manager.createRoadEast(plot);
manager.createRoadSouth(plot);
manager.createRoadSouthEast(plot);