mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Check if location has PlotArea to avoid NPE
This commit is contained in:
parent
d106262454
commit
a94c588a17
@ -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.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
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.PlotManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
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) {
|
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||||
Location loc = player.getLocation();
|
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();
|
Plot plot = player.getCurrentPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
Captions.NOT_IN_PLOT.send(player);
|
Captions.NOT_IN_PLOT.send(player);
|
||||||
} else if (plot.isMerged()) {
|
} else if (plot.isMerged()) {
|
||||||
Captions.REQUIRES_UNMERGED.send(player);
|
Captions.REQUIRES_UNMERGED.send(player);
|
||||||
} else {
|
} else {
|
||||||
|
PlotManager manager = area.getPlotManager();
|
||||||
manager.createRoadEast(plot);
|
manager.createRoadEast(plot);
|
||||||
manager.createRoadSouth(plot);
|
manager.createRoadSouth(plot);
|
||||||
manager.createRoadSouthEast(plot);
|
manager.createRoadSouthEast(plot);
|
||||||
|
Loading…
Reference in New Issue
Block a user