Don't access tree until it has been created

This commit is contained in:
Alexander Söderberg 2020-05-21 20:23:36 +02:00
parent 1c6075df2b
commit 38a7c771be
No known key found for this signature in database
GPG key ID: C0207FF7EA146678

View file

@ -62,6 +62,9 @@ public class ScatteredPlotWorld extends PlotWorld {
}
@Override @Nullable public PlotArea getArea(@NotNull final Location location) {
if (this.areas.isEmpty()) {
return null;
}
synchronized (this.treeLock) {
final Observable<Entry<PlotArea, Geometry>> area =
areaTree.search(Geometries.point(location.getX(), location.getZ()));
@ -87,6 +90,9 @@ public class ScatteredPlotWorld extends PlotWorld {
}
@Override @NotNull public Collection<PlotArea> getAreasInRegion(@NotNull final CuboidRegion region) {
if (this.areas.isEmpty()) {
return Collections.emptyList();
}
synchronized (this.treeLock) {
final List<PlotArea> areas = new LinkedList<>();
this.areaTree.search(RegionUtil.toRectangle(region)).toBlocking().forEach(entry -> areas.add(entry.value()));