Safer generation of the BlockBucketChunk

This commit is contained in:
dordsor21 2019-01-19 16:28:49 +00:00
parent ca883c211a
commit 0609b3d7f6
2 changed files with 22 additions and 4 deletions

View File

@ -74,6 +74,10 @@ public class BukkitHybridUtils extends HybridUtils {
HybridPlotWorld hpw = (HybridPlotWorld) area; HybridPlotWorld hpw = (HybridPlotWorld) area;
final BlockBucket[][] result = hpw.getBlockBucketChunk(); final BlockBucket[][] result = hpw.getBlockBucketChunk();
if (result == null) {
return;
}
if (hpw.PLOT_SCHEMATIC) { if (hpw.PLOT_SCHEMATIC) {
short[] rx = new short[16]; short[] rx = new short[16];
short[] rz = new short[16]; short[] rz = new short[16];
@ -218,7 +222,7 @@ public class BukkitHybridUtils extends HybridUtils {
types.add(now); types.add(now);
} }
} catch (NullPointerException e) { } catch (NullPointerException e) {
PlotSquared.log(old.toString()); PlotSquared.log(old != null ? old.toString() : "old null");
PlotSquared.log(x); PlotSquared.log(x);
PlotSquared.log(y); PlotSquared.log(y);
PlotSquared.log(z); PlotSquared.log(z);

View File

@ -14,7 +14,6 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap; import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import lombok.Getter;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -35,7 +34,7 @@ public abstract class PlotArea {
private final PlotId min; private final PlotId min;
private final PlotId max; private final PlotId max;
private final IndependentPlotGenerator generator; private final IndependentPlotGenerator generator;
@Getter private final BlockBucket[][] blockBucketChunk; private final BlockBucket[][] blockBucketChunk;
public int MAX_PLOT_MEMBERS = 128; public int MAX_PLOT_MEMBERS = 128;
public boolean AUTO_MERGE = false; public boolean AUTO_MERGE = false;
public boolean ALLOW_SIGNS = true; public boolean ALLOW_SIGNS = true;
@ -87,7 +86,7 @@ public abstract class PlotArea {
this.max = max; this.max = max;
} }
this.worldhash = worldName.hashCode(); this.worldhash = worldName.hashCode();
if (Settings.Enabled_Components.PLOT_EXPIRY) { if (Settings.Enabled_Components.PLOT_EXPIRY && generator != null) {
blockBucketChunk = generator.generateBlockBucketChunk(this); blockBucketChunk = generator.generateBlockBucketChunk(this);
} else { } else {
blockBucketChunk = null; blockBucketChunk = null;
@ -113,6 +112,21 @@ public abstract class PlotArea {
return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue); return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue);
} }
/**
* Get an array of BlockBuckets corresponding to a chunk of a plot
*
* @return BlockBucket[][]
*/
public BlockBucket[][] getBlockBucketChunk() {
if (blockBucketChunk != null) {
return blockBucketChunk;
}
if (generator != null) {
return generator.generateBlockBucketChunk(this);
}
return null;
}
/** /**
* Returns the region for this PlotArea or a RegionWrapper encompassing * Returns the region for this PlotArea or a RegionWrapper encompassing
* the whole world if none exists. * the whole world if none exists.