mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Merge pull request #2564 from IntellectualSites/we
Use patterns instead of BlockBucket
This commit is contained in:
commit
10e5760ba8
@ -65,8 +65,6 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
|
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
|
||||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitCommandSender;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
|
@ -2,15 +2,13 @@ package com.github.intellectualsites.plotsquared.bukkit.generator;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
|
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -37,30 +35,6 @@ import java.util.Random;
|
|||||||
return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotArea(world, id, min, max);
|
return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotArea(world, id, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public BlockBucket[][] generateBlockBucketChunk(PlotArea settings) {
|
|
||||||
BlockBucket[][] blockBuckets = new BlockBucket[16][];
|
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
|
||||||
// Bedrock
|
|
||||||
if (hpw.PLOT_BEDROCK) {
|
|
||||||
for (short x = 0; x < 16; x++) {
|
|
||||||
for (short z = 0; z < 16; z++) {
|
|
||||||
blockBuckets[0][(z << 4) | x] =
|
|
||||||
BlockBucket.withSingle(BlockUtil.get("bedrock"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (short x = 0; x < 16; x++) {
|
|
||||||
for (short z = 0; z < 16; z++) {
|
|
||||||
for (int y = 1; y < hpw.PLOT_HEIGHT; y++) {
|
|
||||||
blockBuckets[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = hpw.MAIN_BLOCK;
|
|
||||||
}
|
|
||||||
blockBuckets[hpw.PLOT_HEIGHT >> 4][((hpw.PLOT_HEIGHT & 0xF) << 8) | (z << 4) | x] =
|
|
||||||
hpw.MAIN_BLOCK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return blockBuckets;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
|
@Override public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
|
||||||
World world = BukkitUtil.getWorld(this.world);
|
World world = BukkitUtil.getWorld(this.world);
|
||||||
Location min = result.getMin();
|
Location min = result.getMin();
|
||||||
@ -71,7 +45,7 @@ import java.util.Random;
|
|||||||
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
|
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
|
||||||
@Override public void setBiome(@Range(from = 0, to = 15) int x,
|
@Override public void setBiome(@Range(from = 0, to = 15) int x,
|
||||||
@Range(from = 0, to = 15) int z, Biome biome) {
|
@Range(from = 0, to = 15) int z, Biome biome) {
|
||||||
result.setBiome(x, z, biome.name());
|
result.setBiome(x, z, BukkitAdapter.adapt(biome));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @NotNull public Biome getBiome(int x, int z) {
|
@Override @NotNull public Biome getBiome(int x, int z) {
|
||||||
|
@ -12,7 +12,6 @@ import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
|
@ -9,19 +9,19 @@ 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.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotLoc;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotLoc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
|
||||||
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 com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -370,7 +370,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (id != null) {
|
if (id != null) {
|
||||||
value.setBlock(x1, y, z1, id);
|
value.setBlock(x1, y, z1, id);
|
||||||
} else {
|
} else {
|
||||||
value.setBlock(x1, y, z1, BlockUtil.get("air"));
|
value.setBlock(x1, y, z1, BlockTypes.AIR.getDefaultState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int y = Math.min(128, ids.length);
|
for (int y = Math.min(128, ids.length);
|
||||||
|
@ -1,321 +1,8 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.util;
|
package com.github.intellectualsites.plotsquared.bukkit.util;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
|
||||||
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.expiry.PlotAnalysis;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.block.data.Directional;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class BukkitHybridUtils extends HybridUtils {
|
public class BukkitHybridUtils extends HybridUtils {
|
||||||
|
|
||||||
@Override public void analyzeRegion(final String world, final CuboidRegion region,
|
|
||||||
final RunnableVal<PlotAnalysis> whenDone) {
|
|
||||||
// int diff, int variety, int vertices, int rotation, int height_sd
|
|
||||||
/*
|
|
||||||
* diff: compare to base by looping through all blocks
|
|
||||||
* variety: add to HashSet for each BlockState
|
|
||||||
* height_sd: loop over all blocks and get top block
|
|
||||||
*
|
|
||||||
* vertices: store air map and compare with neighbours
|
|
||||||
* for each block check the adjacent
|
|
||||||
* - Store all blocks then go through in second loop
|
|
||||||
* - recheck each block
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
TaskManager.runTaskAsync(() -> {
|
|
||||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
|
||||||
final World worldObj = Bukkit.getWorld(world);
|
|
||||||
final ChunkGenerator chunkGenerator = worldObj.getGenerator();
|
|
||||||
if (!(chunkGenerator instanceof BukkitPlotGenerator)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location bot = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
|
|
||||||
final Location top = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
|
|
||||||
|
|
||||||
final int bx = bot.getX();
|
|
||||||
final int bz = bot.getZ();
|
|
||||||
final int tx = top.getX();
|
|
||||||
final int tz = top.getZ();
|
|
||||||
final int cbx = bx >> 4;
|
|
||||||
final int cbz = bz >> 4;
|
|
||||||
final int ctx = tx >> 4;
|
|
||||||
final int ctz = tz >> 4;
|
|
||||||
MainUtil.initCache();
|
|
||||||
final int width = tx - bx + 1;
|
|
||||||
final int length = tz - bz + 1;
|
|
||||||
|
|
||||||
System.gc();
|
|
||||||
System.gc();
|
|
||||||
final BlockBucket[][][] oldBlocks = new BlockBucket[256][width][length];
|
|
||||||
final BlockState[][][] newBlocks = new BlockState[256][width][length];
|
|
||||||
final BlockBucket airBucket = BlockBucket.withSingle(BlockTypes.AIR.getDefaultState());
|
|
||||||
|
|
||||||
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
|
||||||
|
|
||||||
if (!(area instanceof HybridPlotWorld)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) area;
|
|
||||||
final BlockBucket[][] result = hpw.getBlockBucketChunk();
|
|
||||||
|
|
||||||
if (result == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hpw.PLOT_SCHEMATIC) {
|
|
||||||
short[] rx = new short[16];
|
|
||||||
short[] rz = new short[16];
|
|
||||||
short rbx;
|
|
||||||
short rbz;
|
|
||||||
if (bx < 0) {
|
|
||||||
rbx = (short) (hpw.SIZE + (bx % hpw.SIZE));
|
|
||||||
} else {
|
|
||||||
rbx = (short) (bx % hpw.SIZE);
|
|
||||||
}
|
|
||||||
if (bz < 0) {
|
|
||||||
rbz = (short) (hpw.SIZE + (bz % hpw.SIZE));
|
|
||||||
} else {
|
|
||||||
rbz = (short) (bz % hpw.SIZE);
|
|
||||||
}
|
|
||||||
for (short i = 0; i < 16; i++) {
|
|
||||||
short v = (short) (rbx + i);
|
|
||||||
if (v >= hpw.SIZE) {
|
|
||||||
v -= hpw.SIZE;
|
|
||||||
}
|
|
||||||
rx[i] = v;
|
|
||||||
}
|
|
||||||
for (short i = 0; i < 16; i++) {
|
|
||||||
short v = (short) (rbz + i);
|
|
||||||
if (v >= hpw.SIZE) {
|
|
||||||
v -= hpw.SIZE;
|
|
||||||
}
|
|
||||||
rz[i] = v;
|
|
||||||
}
|
|
||||||
int minY;
|
|
||||||
if (Settings.Schematics.PASTE_ON_TOP) {
|
|
||||||
minY = hpw.SCHEM_Y;
|
|
||||||
} else {
|
|
||||||
minY = 1;
|
|
||||||
}
|
|
||||||
for (short x = 0; x < 16; x++) {
|
|
||||||
for (short z = 0; z < 16; z++) {
|
|
||||||
BaseBlock[] blocks = hpw.G_SCH.get(MathMan.pair(rx[x], rz[z]));
|
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
|
||||||
if (blocks[y] != null) {
|
|
||||||
result[(minY + y) >> 4][(((minY + y) & 0xF) << 8) | (z << 4) | x] =
|
|
||||||
BlockBucket.withSingle(blocks[y].toImmutableState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Runnable run = () -> ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
|
|
||||||
@Override public void run(int[] value) {
|
|
||||||
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
|
|
||||||
int X = value[0];
|
|
||||||
int Z = value[1];
|
|
||||||
int xb = (X << 4) - bx;
|
|
||||||
int zb = (Z << 4) - bz;
|
|
||||||
for (int i = 0; i < result.length; i++) {
|
|
||||||
if (result[i] == null) {
|
|
||||||
for (int j = 0; j < 4096; j++) {
|
|
||||||
int x = MainUtil.x_loc[i][j] + xb;
|
|
||||||
if (x < 0 || x >= width) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int z = MainUtil.z_loc[i][j] + zb;
|
|
||||||
if (z < 0 || z >= length) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int y = MainUtil.y_loc[i][j];
|
|
||||||
oldBlocks[y][x][z] = airBucket;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (int j = 0; j < result[i].length; j++) {
|
|
||||||
int x = MainUtil.x_loc[i][j] + xb;
|
|
||||||
if (x < 0 || x >= width) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int z = MainUtil.z_loc[i][j] + zb;
|
|
||||||
if (z < 0 || z >= length) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int y = MainUtil.y_loc[i][j];
|
|
||||||
oldBlocks[y][x][z] = result[i][j] != null ? result[i][j] : airBucket;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}, () -> TaskManager.runTaskAsync(() -> {
|
|
||||||
int size = width * length;
|
|
||||||
int[] changes = new int[size];
|
|
||||||
int[] faces = new int[size];
|
|
||||||
int[] data = new int[size];
|
|
||||||
int[] air = new int[size];
|
|
||||||
int[] variety = new int[size];
|
|
||||||
int i = 0;
|
|
||||||
for (int x = 0; x < width; x++) {
|
|
||||||
for (int z = 0; z < length; z++) {
|
|
||||||
Set<BlockType> types = new HashSet<>();
|
|
||||||
for (int y = 0; y < 256; y++) {
|
|
||||||
BlockBucket old = oldBlocks[y][x][z];
|
|
||||||
try {
|
|
||||||
if (old == null) {
|
|
||||||
old = airBucket;
|
|
||||||
}
|
|
||||||
BlockState now = newBlocks[y][x][z];
|
|
||||||
if (!old.getBlocks().contains(now)) {
|
|
||||||
changes[i]++;
|
|
||||||
}
|
|
||||||
if (now.getBlockType().getMaterial().isAir()) {
|
|
||||||
air[i]++;
|
|
||||||
} else {
|
|
||||||
// check vertices
|
|
||||||
// modifications_adjacent
|
|
||||||
if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1
|
|
||||||
&& y < 255) {
|
|
||||||
if (newBlocks[y - 1][x][z].getBlockType().getMaterial().isAir()) {
|
|
||||||
faces[i]++;
|
|
||||||
}
|
|
||||||
if (newBlocks[y][x - 1][z].getBlockType().getMaterial().isAir()) {
|
|
||||||
faces[i]++;
|
|
||||||
}
|
|
||||||
if (newBlocks[y][x][z - 1].getBlockType().getMaterial().isAir()) {
|
|
||||||
faces[i]++;
|
|
||||||
}
|
|
||||||
if (newBlocks[y + 1][x][z].getBlockType().getMaterial().isAir()) {
|
|
||||||
faces[i]++;
|
|
||||||
}
|
|
||||||
if (newBlocks[y][x + 1][z].getBlockType().getMaterial().isAir()) {
|
|
||||||
faces[i]++;
|
|
||||||
}
|
|
||||||
if (newBlocks[y][x][z + 1].getBlockType().getMaterial().isAir()) {
|
|
||||||
faces[i]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Material material = BukkitAdapter.adapt(now.getBlockType());
|
|
||||||
if (material != null) {
|
|
||||||
BlockData blockData = material.createBlockData();
|
|
||||||
if (blockData instanceof Directional) {
|
|
||||||
data[i] += 8;
|
|
||||||
} else if (!blockData.getClass().equals(BlockData.class)) {
|
|
||||||
data[i]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
types.add(now.getBlockType());
|
|
||||||
}
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
variety[i] = types.size();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// analyze plot
|
|
||||||
// put in analysis obj
|
|
||||||
|
|
||||||
// run whenDone
|
|
||||||
PlotAnalysis analysis = new PlotAnalysis();
|
|
||||||
analysis.changes = (int) (MathMan.getMean(changes) * 100);
|
|
||||||
analysis.faces = (int) (MathMan.getMean(faces) * 100);
|
|
||||||
analysis.data = (int) (MathMan.getMean(data) * 100);
|
|
||||||
analysis.air = (int) (MathMan.getMean(air) * 100);
|
|
||||||
analysis.variety = (int) (MathMan.getMean(variety) * 100);
|
|
||||||
|
|
||||||
analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes) * 100);
|
|
||||||
analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces) * 100);
|
|
||||||
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data) * 100);
|
|
||||||
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air) * 100);
|
|
||||||
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety) * 100);
|
|
||||||
System.gc();
|
|
||||||
System.gc();
|
|
||||||
whenDone.value = analysis;
|
|
||||||
whenDone.run();
|
|
||||||
}), 5);
|
|
||||||
System.gc();
|
|
||||||
MainUtil.initCache();
|
|
||||||
ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
|
|
||||||
@Override public void run(int[] value) {
|
|
||||||
int X = value[0];
|
|
||||||
int Z = value[1];
|
|
||||||
worldObj.loadChunk(X, Z);
|
|
||||||
int minX;
|
|
||||||
if (X == cbx) {
|
|
||||||
minX = bx & 15;
|
|
||||||
} else {
|
|
||||||
minX = 0;
|
|
||||||
}
|
|
||||||
int minZ;
|
|
||||||
if (Z == cbz) {
|
|
||||||
minZ = bz & 15;
|
|
||||||
} else {
|
|
||||||
minZ = 0;
|
|
||||||
}
|
|
||||||
int maxX;
|
|
||||||
if (X == ctx) {
|
|
||||||
maxX = tx & 15;
|
|
||||||
} else {
|
|
||||||
maxX = 16;
|
|
||||||
}
|
|
||||||
int maxZ;
|
|
||||||
if (Z == ctz) {
|
|
||||||
maxZ = tz & 15;
|
|
||||||
} else {
|
|
||||||
maxZ = 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cbx = X << 4;
|
|
||||||
int cbz = Z << 4;
|
|
||||||
|
|
||||||
int xb = cbx - bx;
|
|
||||||
int zb = cbz - bz;
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
|
||||||
int xx = cbx + x;
|
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
|
||||||
int zz = cbz + z;
|
|
||||||
for (int y = 0; y < 256; y++) {
|
|
||||||
BlockState block = queue.getBlock(xx, y, zz);
|
|
||||||
int xr = xb + x;
|
|
||||||
int zr = zb + z;
|
|
||||||
newBlocks[y][xr][zr] = block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
worldObj.unloadChunkRequest(X, Z);
|
|
||||||
}
|
|
||||||
}, () -> TaskManager.runTaskAsync(run), 5);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper;
|
import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||||
|
@ -3,8 +3,6 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
|
|||||||
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
|
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class BukkitTaskManager extends TaskManager {
|
public class BukkitTaskManager extends TaskManager {
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ 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.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
@ -18,6 +17,8 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -39,7 +40,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -279,8 +279,8 @@ import java.util.Set;
|
|||||||
return getWorld(worldName) != null;
|
return getWorld(worldName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getBiome(String world, int x, int z) {
|
@Override public BiomeType getBiome(String world, int x, int z) {
|
||||||
return getWorld(world).getBiome(x, z).name();
|
return BukkitAdapter.adapt(getWorld(world).getBiome(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getHighestBlock(@NonNull final String world, final int x, final int z) {
|
@Override public int getHighestBlock(@NonNull final String world, final int x, final int z) {
|
||||||
@ -380,20 +380,6 @@ import java.util.Set;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getBiomeFromString(@NonNull final String biomeString) {
|
|
||||||
try {
|
|
||||||
final Biome biome = Biome.valueOf(biomeString.toUpperCase());
|
|
||||||
return Arrays.asList(Biome.values()).indexOf(biome);
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String[] getBiomeList() {
|
|
||||||
final Biome[] biomes = Biome.values();
|
|
||||||
return Arrays.stream(biomes).map(Enum::name).toArray(String[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) {
|
public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) {
|
||||||
final World world = getWorld(worldName);
|
final World world = getWorld(worldName);
|
||||||
@ -433,9 +419,9 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBiomes(@NonNull final String worldName, @NonNull final CuboidRegion region,
|
public void setBiomes(@NonNull final String worldName, @NonNull final CuboidRegion region,
|
||||||
@NonNull final String biomeString) {
|
@NonNull final BiomeType biomeType) {
|
||||||
final World world = getWorld(worldName);
|
final World world = getWorld(worldName);
|
||||||
final Biome biome = Biome.valueOf(biomeString.toUpperCase());
|
final Biome biome = BukkitAdapter.adapt(biomeType);
|
||||||
for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
|
for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
|
||||||
for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
|
for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
|
||||||
world.setBiome(x, z, biome);
|
world.setBiome(x, z, biome);
|
||||||
@ -450,7 +436,7 @@ import java.util.Set;
|
|||||||
@Override public BlockState getBlock(@NonNull final Location location) {
|
@Override public BlockState getBlock(@NonNull final Location location) {
|
||||||
final World world = getWorld(location.getWorld());
|
final World world = getWorld(location.getWorld());
|
||||||
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
return BlockUtil.get(block.getType().name());
|
return BukkitAdapter.asBlockType(block.getType()).getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getMainWorld() {
|
@Override public String getMainWorld() {
|
||||||
|
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQ
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
@ -130,11 +131,11 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
|
|||||||
int bx = lc.getX() << 4;
|
int bx = lc.getX() << 4;
|
||||||
int bz = lc.getX() << 4;
|
int bz = lc.getX() << 4;
|
||||||
for (int x = 0; x < lc.biomes.length; x++) {
|
for (int x = 0; x < lc.biomes.length; x++) {
|
||||||
String[] biomes2 = lc.biomes[x];
|
BiomeType[] biomes2 = lc.biomes[x];
|
||||||
if (biomes2 != null) {
|
if (biomes2 != null) {
|
||||||
for (String biomeStr : biomes2) {
|
for (BiomeType biomeStr : biomes2) {
|
||||||
if (biomeStr != null) {
|
if (biomeStr != null) {
|
||||||
Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
Biome biome = BukkitAdapter.adapt(biomeStr);
|
||||||
worldObj.setBiome(bx, bz, biome);
|
worldObj.setBiome(bx, bz, biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,14 @@ import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
|
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.PatternUtil;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -57,11 +60,11 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
chunkZ = wrap.z;
|
chunkZ = wrap.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void fillBiome(String biomeName) {
|
@Override public void fillBiome(BiomeType biomeType) {
|
||||||
if (biomeGrid == null) {
|
if (biomeGrid == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Biome biome = Biome.valueOf(biomeName.toUpperCase());
|
Biome biome = BukkitAdapter.adapt(biomeType);
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
this.biomeGrid.setBiome(x, z, biome);
|
this.biomeGrid.setBiome(x, z, biome);
|
||||||
@ -92,8 +95,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
chunkData.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, BukkitAdapter.adapt(block));
|
chunkData.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, BukkitAdapter.adapt(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int z, String biome) {
|
@Override public boolean setBiome(int x, int z, BiomeType biomeType) {
|
||||||
return setBiome(x, z, Biome.valueOf(biome.toUpperCase()));
|
return setBiome(x, z, BukkitAdapter.adapt(biomeType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setBiome(int x, int z, Biome biome) {
|
public boolean setBiome(int x, int z, Biome biome) {
|
||||||
@ -104,6 +107,10 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||||
|
return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean setBlock(int x, int y, int z, BlockState id) {
|
@Override public boolean setBlock(int x, int y, int z, BlockState id) {
|
||||||
if (this.result == null) {
|
if (this.result == null) {
|
||||||
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
|
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
|
||||||
@ -130,7 +137,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
|
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
|
||||||
this.storeCache(x, y, z, BlockUtil.get(id.getBlockType().getId()));
|
this.storeCache(x, y, z, id.toImmutableState());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +148,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
}
|
}
|
||||||
BlockState[] array = result[i];
|
BlockState[] array = result[i];
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return BlockUtil.get("");
|
return BlockTypes.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
int j = MainUtil.CACHE_J[y][x][z];
|
int j = MainUtil.CACHE_J[y][x][z];
|
||||||
return array[j];
|
return array[j];
|
||||||
|
@ -14,7 +14,6 @@ import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -29,7 +29,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotFilter;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
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.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.DefaultPlotAreaManager;
|
import com.github.intellectualsites.plotsquared.plot.object.worlds.DefaultPlotAreaManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
|
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
|
||||||
@ -56,6 +55,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpiryTask;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpiryTask;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -12,8 +12,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
|
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
|
||||||
@ -25,7 +23,9 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -6,7 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|||||||
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;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
|
|
||||||
@CommandDeclaration(command = "setbiome", permission = "plots.set.biome",
|
@CommandDeclaration(command = "setbiome", permission = "plots.set.biome",
|
||||||
description = "Set the plot biome", usage = "/plot biome [biome]",
|
description = "Set the plot biome", usage = "/plot biome [biome]",
|
||||||
@ -14,25 +15,26 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
|||||||
requiredType = RequiredType.NONE) public class Biome extends SetCommand {
|
requiredType = RequiredType.NONE) public class Biome extends SetCommand {
|
||||||
|
|
||||||
@Override public boolean set(final PlotPlayer player, final Plot plot, final String value) {
|
@Override public boolean set(final PlotPlayer player, final Plot plot, final String value) {
|
||||||
int biome = WorldUtil.IMP.getBiomeFromString(value);
|
try {
|
||||||
if (biome == -1) {
|
BiomeType biome = BiomeTypes.get(value);
|
||||||
|
if (plot.getRunning() > 0) {
|
||||||
|
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
plot.addRunning();
|
||||||
|
plot.setBiome(biome, () -> {
|
||||||
|
plot.removeRunning();
|
||||||
|
MainUtil
|
||||||
|
.sendMessage(player, Captions.BIOME_SET_TO.getTranslated() + value.toLowerCase());
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (IllegalStateException ignore) {
|
||||||
String biomes = StringMan
|
String biomes = StringMan
|
||||||
.join(WorldUtil.IMP.getBiomeList(), Captions.BLOCK_LIST_SEPARATOR.getTranslated());
|
.join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated());
|
||||||
Captions.NEED_BIOME.send(player);
|
Captions.NEED_BIOME.send(player);
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + biomes);
|
Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + biomes);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot.getRunning() > 0) {
|
|
||||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
plot.addRunning();
|
|
||||||
plot.setBiome(value.toUpperCase(), () -> {
|
|
||||||
plot.removeRunning();
|
|
||||||
MainUtil
|
|
||||||
.sendMessage(player, Captions.BIOME_SET_TO.getTranslated() + value.toLowerCase());
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class Info extends SubCommand {
|
|||||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info",
|
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info",
|
||||||
"&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name,
|
"&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name,
|
||||||
"&cAlias: &6" + plot.getAlias(),
|
"&cAlias: &6" + plot.getAlias(),
|
||||||
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
|
"&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(),
|
||||||
"&cCan Build: &6" + plot.isAdded(uuid),
|
"&cCan Build: &6" + plot.isAdded(uuid),
|
||||||
"&cSeen: &6" + MainUtil.secToTime((int) (ExpireManager.IMP.getAge(plot) / 1000)),
|
"&cSeen: &6" + MainUtil.secToTime((int) (ExpireManager.IMP.getAge(plot) / 1000)),
|
||||||
"&cIs Denied: &6" + plot.isDenied(uuid)));
|
"&cIs Denied: &6" + plot.isDenied(uuid)));
|
||||||
|
@ -3,22 +3,18 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
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.config.Configuration;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration.UnknownBlockException;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
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;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.github.intellectualsites.plotsquared.plot.util.world.PatternUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -60,51 +56,19 @@ import java.util.stream.IntStream;
|
|||||||
Captions.PERMISSION_SET_COMPONENT.f(component));
|
Captions.PERMISSION_SET_COMPONENT.f(component));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// BlockState[] blocks;
|
if (args.length < 2) {
|
||||||
BlockBucket bucket;
|
MainUtil.sendMessage(player, Captions.NEED_BLOCK);
|
||||||
try {
|
return true;
|
||||||
if (args.length < 2) {
|
|
||||||
MainUtil.sendMessage(player, Captions.NEED_BLOCK);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
bucket = Configuration.BLOCK_BUCKET.parseString(material);
|
|
||||||
} catch (final UnknownBlockException unknownBlockException) {
|
|
||||||
final String unknownBlock = unknownBlockException.getUnknownValue();
|
|
||||||
Captions.NOT_VALID_BLOCK.send(player, unknownBlock);
|
|
||||||
StringComparison<BlockState>.ComparisonResult match =
|
|
||||||
WorldUtil.IMP.getClosestBlock(unknownBlock);
|
|
||||||
if (match != null) {
|
|
||||||
final String found =
|
|
||||||
WorldUtil.IMP.getClosestMatchingName(match.best);
|
|
||||||
if (found != null) {
|
|
||||||
MainUtil.sendMessage(player, Captions.DID_YOU_MEAN,
|
|
||||||
found.toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!allowUnsafe) {
|
|
||||||
for (final BlockState block : bucket.getBlocks()) {
|
|
||||||
if (!block.getBlockType().getMaterial().isAir() && !WorldUtil.IMP.isBlockSolid(block)) {
|
|
||||||
Captions.NOT_ALLOWED_BLOCK.send(player, block.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
MainUtil.sendMessage(player, Captions.NOT_VALID_BLOCK, material);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pattern pattern = PatternUtil.parse(player, material);
|
||||||
if (plot.getRunning() > 0) {
|
if (plot.getRunning() > 0) {
|
||||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plot.addRunning();
|
plot.addRunning();
|
||||||
for (Plot current : plot.getConnectedPlots()) {
|
for (Plot current : plot.getConnectedPlots()) {
|
||||||
current.setComponent(component, bucket);
|
current.setComponent(component, pattern);
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||||
GlobalBlockQueue.IMP.addEmptyTask(plot::removeRunning);
|
GlobalBlockQueue.IMP.addEmptyTask(plot::removeRunning);
|
||||||
|
@ -6,8 +6,6 @@ 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.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
@ -17,7 +15,9 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
|||||||
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 com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -13,7 +13,6 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.config;
|
package com.github.intellectualsites.plotsquared.plot.config;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Configuration Utility
|
* Main Configuration Utility
|
||||||
@ -43,88 +42,39 @@ public class Configuration {
|
|||||||
return Boolean.parseBoolean(string);
|
return Boolean.parseBoolean(string);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final SettingValue<String> BIOME = new SettingValue<String>("BIOME") {
|
public static final SettingValue<BiomeType> BIOME = new SettingValue<BiomeType>("BIOME") {
|
||||||
@Override public boolean validateValue(String string) {
|
@Override public boolean validateValue(String string) {
|
||||||
try {
|
try {
|
||||||
int biome = WorldUtil.IMP.getBiomeFromString(string.toUpperCase());
|
return BiomeTypes.get(string) != null;
|
||||||
return biome != -1;
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String parseString(String string) {
|
@Override public BiomeType parseString(String string) {
|
||||||
if (validateValue(string)) {
|
if (validateValue(string)) {
|
||||||
return string.toUpperCase();
|
return BiomeTypes.get(string.toUpperCase());
|
||||||
}
|
}
|
||||||
return "FOREST";
|
return BiomeTypes.FOREST;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final SettingValue<BlockBucket> BLOCK_BUCKET =
|
public static final SettingValue<BlockBucket> BLOCK_BUCKET =
|
||||||
new SettingValue<BlockBucket>("BLOCK_BUCKET") {
|
new SettingValue<BlockBucket>("BLOCK_BUCKET") {
|
||||||
|
|
||||||
private Pattern pattern = Pattern.compile("((?<namespace>[A-Za-z_]+):)?(?<block>([A-Za-z_]+(\\[?[\\S\\s]+\\])?))(:(?<chance>[0-9]{1,3}))?");
|
|
||||||
|
|
||||||
@Override public BlockBucket parseString(final String string) {
|
@Override public BlockBucket parseString(final String string) {
|
||||||
if (string == null || string.isEmpty()) {
|
BlockBucket bucket = new BlockBucket(string);
|
||||||
return new BlockBucket();
|
bucket.compile();
|
||||||
}
|
Pattern pattern = bucket.toPattern();
|
||||||
final BlockBucket blockBucket = new BlockBucket();
|
return pattern != null ? bucket : null;
|
||||||
final String[] parts = string.split(",(?![^\\(\\[]*[\\]\\)])");
|
|
||||||
for (final String part : parts) {
|
|
||||||
Matcher matcher = pattern.matcher(part);
|
|
||||||
matcher.find();
|
|
||||||
String namespace = matcher.group("namespace");
|
|
||||||
String block = matcher.group("block");
|
|
||||||
String chanceStr = matcher.group("chance");
|
|
||||||
if (namespace == null) namespace = "minecraft";
|
|
||||||
int chance = chanceStr == null ? -1 : Integer.parseInt(chanceStr);
|
|
||||||
final StringComparison<BlockState>.ComparisonResult value =
|
|
||||||
WorldUtil.IMP.getClosestBlock(block);
|
|
||||||
if (value == null) {
|
|
||||||
throw new UnknownBlockException(block);
|
|
||||||
} else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.getBlockType().getMaterial().isAir()
|
|
||||||
&& !WorldUtil.IMP.isBlockSolid(value.best)) {
|
|
||||||
throw new UnsafeBlockException(value.best);
|
|
||||||
}
|
|
||||||
blockBucket.addBlock(value.best, chance);
|
|
||||||
}
|
|
||||||
blockBucket.compile(); // Pre-compile :D
|
|
||||||
return blockBucket;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean validateValue(final String string) {
|
@Override public boolean validateValue(final String string) {
|
||||||
try {
|
try {
|
||||||
if (string == null || string.isEmpty()) {
|
return parseString(string) != null;
|
||||||
return false;
|
} catch (Exception e) {
|
||||||
}
|
|
||||||
final String[] parts = string.split(",(?![^\\(\\[]*[\\]\\)])");
|
|
||||||
for (final String part : parts) {
|
|
||||||
Matcher matcher = pattern.matcher(part);
|
|
||||||
matcher.find();
|
|
||||||
String namespace = matcher.group("namespace");
|
|
||||||
String block = matcher.group("block");
|
|
||||||
String chanceStr = matcher.group("chance");
|
|
||||||
if (namespace == null) namespace = "minecraft";
|
|
||||||
int chance = chanceStr == null ? -1 : Integer.parseInt(chanceStr);
|
|
||||||
|
|
||||||
if ((chance != -1 && (chance < 1 || chance > 100)) || block == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
StringComparison<BlockState>.ComparisonResult value =
|
|
||||||
WorldUtil.IMP.getClosestBlock(block);
|
|
||||||
if (value == null || value.match > 1) {
|
|
||||||
return false;
|
|
||||||
} else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.getBlockType().getMaterial().isAir()
|
|
||||||
&& !WorldUtil.IMP.isBlockSolid(value.best)) {
|
|
||||||
throw new UnsafeBlockException(value.best);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (final Throwable exception) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,12 +4,13 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
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.util.world.RegionUtil;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue;
|
||||||
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 com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -72,7 +73,7 @@ public class AugmentedUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int z, String biome) {
|
@Override public boolean setBiome(int x, int z, BiomeType biome) {
|
||||||
if (area.contains(x, z)) {
|
if (area.contains(x, z)) {
|
||||||
return super.setBiome(x, z, biome);
|
return super.setBiome(x, z, biome);
|
||||||
}
|
}
|
||||||
@ -116,7 +117,7 @@ public class AugmentedUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int y, String biome) {
|
@Override public boolean setBiome(int x, int y, BiomeType biome) {
|
||||||
return super.setBiome(x, y, biome);
|
return super.setBiome(x, y, biome);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,14 +6,17 @@ import com.github.intellectualsites.plotsquared.plot.object.Direction;
|
|||||||
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.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
|
||||||
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 com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.intellectualsites.plotsquared.plot.util.world.PatternUtil.isAir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A plot manager with square plots which tessellate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot).
|
* A plot manager with square plots which tessellate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot).
|
||||||
*/
|
*/
|
||||||
@ -27,7 +30,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setComponent(PlotId plotId, String component,
|
@Override public boolean setComponent(PlotId plotId, String component,
|
||||||
BlockBucket blocks) {
|
Pattern blocks) {
|
||||||
switch (component) {
|
switch (component) {
|
||||||
case "floor":
|
case "floor":
|
||||||
return setFloor(plotId, blocks);
|
return setFloor(plotId, blocks);
|
||||||
@ -50,14 +53,14 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
||||||
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING);
|
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING.toPattern());
|
||||||
if (!classicPlotWorld.WALL_BLOCK.isAir() || !classicPlotWorld.WALL_BLOCK.equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) {
|
if (!classicPlotWorld.WALL_BLOCK.isAir() || !classicPlotWorld.WALL_BLOCK.equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) {
|
||||||
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
|
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
return GlobalBlockQueue.IMP.addEmptyTask(whenDone);
|
return GlobalBlockQueue.IMP.addEmptyTask(whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setFloor(PlotId plotId, BlockBucket blocks) {
|
public boolean setFloor(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||||
if (plot.isBasePlot()) {
|
if (plot.isBasePlot()) {
|
||||||
@ -72,7 +75,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setAll(PlotId plotId, BlockBucket blocks) {
|
public boolean setAll(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
if (!plot.isBasePlot()) {
|
if (!plot.isBasePlot()) {
|
||||||
return false;
|
return false;
|
||||||
@ -87,7 +90,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setAir(PlotId plotId, BlockBucket blocks) {
|
public boolean setAir(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
if (!plot.isBasePlot()) {
|
if (!plot.isBasePlot()) {
|
||||||
return false;
|
return false;
|
||||||
@ -103,7 +106,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setMain(PlotId plotId, BlockBucket blocks) {
|
public boolean setMain(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
if (!plot.isBasePlot()) {
|
if (!plot.isBasePlot()) {
|
||||||
return false;
|
return false;
|
||||||
@ -118,7 +121,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setMiddle(PlotId plotId, BlockBucket blocks) {
|
public boolean setMiddle(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
if (!plot.isBasePlot()) {
|
if (!plot.isBasePlot()) {
|
||||||
return false;
|
return false;
|
||||||
@ -128,11 +131,11 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
|
|
||||||
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
||||||
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
||||||
queue.setBlock(x, classicPlotWorld.PLOT_HEIGHT, z, blocks.getBlock());
|
queue.setBlock(x, classicPlotWorld.PLOT_HEIGHT, z, blocks);
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setOutline(PlotId plotId, BlockBucket blocks) {
|
public boolean setOutline(PlotId plotId, Pattern blocks) {
|
||||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -145,7 +148,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int z = bottom.getZ();
|
int z = bottom.getZ();
|
||||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||||
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +156,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int x = bottom.getX();
|
int x = bottom.getX();
|
||||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||||
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +165,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int z = top.getZ();
|
int z = top.getZ();
|
||||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||||
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +173,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int x = top.getX();
|
int x = top.getX();
|
||||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||||
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,7 +187,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setWallFilling(PlotId plotId, BlockBucket blocks) {
|
public boolean setWallFilling(PlotId plotId, Pattern blocks) {
|
||||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -198,7 +201,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int z = bot.getZ();
|
int z = bot.getZ();
|
||||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||||
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,7 +209,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int x = bot.getX();
|
int x = bot.getX();
|
||||||
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
||||||
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,7 +218,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
for (int x = bot.getX();
|
for (int x = bot.getX();
|
||||||
x < top.getX() + (plot.getMerged(Direction.EAST) ? 0 : 1); x++) {
|
x < top.getX() + (plot.getMerged(Direction.EAST) ? 0 : 1); x++) {
|
||||||
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,14 +227,14 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
for (int z = bot.getZ();
|
for (int z = bot.getZ();
|
||||||
z < top.getZ() + (plot.getMerged(Direction.SOUTH) ? 0 : 1); z++) {
|
z < top.getZ() + (plot.getMerged(Direction.SOUTH) ? 0 : 1); z++) {
|
||||||
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setWall(PlotId plotId, BlockBucket blocks) {
|
public boolean setWall(PlotId plotId, Pattern blocks) {
|
||||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -245,27 +248,27 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
if (!plot.getMerged(Direction.NORTH)) {
|
if (!plot.getMerged(Direction.NORTH)) {
|
||||||
int z = bot.getZ();
|
int z = bot.getZ();
|
||||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getMerged(Direction.WEST)) {
|
if (!plot.getMerged(Direction.WEST)) {
|
||||||
int x = bot.getX();
|
int x = bot.getX();
|
||||||
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getMerged(Direction.SOUTH)) {
|
if (!plot.getMerged(Direction.SOUTH)) {
|
||||||
int z = top.getZ();
|
int z = top.getZ();
|
||||||
for (int x = bot.getX();
|
for (int x = bot.getX();
|
||||||
x < top.getX() + (plot.getMerged(Direction.EAST) ? 0 : 1); x++) {
|
x < top.getX() + (plot.getMerged(Direction.EAST) ? 0 : 1); x++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getMerged(Direction.EAST)) {
|
if (!plot.getMerged(Direction.EAST)) {
|
||||||
int x = top.getX();
|
int x = top.getX();
|
||||||
for (int z = bot.getZ();
|
for (int z = bot.getZ();
|
||||||
z < top.getZ() + (plot.getMerged(Direction.SOUTH) ? 0 : 1); z++) {
|
z < top.getZ() + (plot.getMerged(Direction.SOUTH) ? 0 : 1); z++) {
|
||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
@ -290,15 +293,15 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 0, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 0, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex, 0, ez - 1), BlockUtil.get((short) 7, (byte) 0));
|
new Location(classicPlotWorld.worldname, ex, 0, ez - 1), BlockUtil.get((short) 7, (byte) 0));
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING);
|
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK);
|
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, ex, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, ex, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,15 +321,15 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, 0, ez), BlockUtil.get((short) 7, (byte) 0));
|
new Location(classicPlotWorld.worldname, ex - 1, 0, ez), BlockUtil.get((short) 7, (byte) 0));
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, sz), classicPlotWorld.WALL_FILLING);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, sz), classicPlotWorld.WALL_FILLING.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, sz), classicPlotWorld.WALL_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, sz), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, ez),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, ez),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, ez), classicPlotWorld.WALL_FILLING);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, ez), classicPlotWorld.WALL_FILLING.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, ez),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, ez),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez), classicPlotWorld.WALL_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +347,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex - 1, 0, ez - 1),
|
new Location(classicPlotWorld.worldname, ex - 1, 0, ez - 1),
|
||||||
BlockUtil.get((short) 7, (byte) 0));
|
BlockUtil.get((short) 7, (byte) 0));
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,9 +365,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||||
BlockUtil.get((short) 0, (byte) 0));
|
BlockUtil.get((short) 0, (byte) 0));
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), classicPlotWorld.MAIN_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), classicPlotWorld.TOP_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), classicPlotWorld.TOP_BLOCK.toPattern());
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,9 +385,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||||
BlockUtil.get((short) 0, (byte) 0));
|
BlockUtil.get((short) 0, (byte) 0));
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), classicPlotWorld.TOP_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), classicPlotWorld.TOP_BLOCK.toPattern());
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,9 +402,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||||
BlockUtil.get((short) 0, (byte) 0));
|
BlockUtil.get((short) 0, (byte) 0));
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT, ez), classicPlotWorld.TOP_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT, ez), classicPlotWorld.TOP_BLOCK.toPattern());
|
||||||
return queue.enqueue();
|
return queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,13 +417,13 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||||
for (PlotId plotId : plotIds) {
|
for (PlotId plotId : plotIds) {
|
||||||
setWall(plotId, claim);
|
setWall(plotId, claim.toPattern());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.General.MERGE_REPLACE_WALL) {
|
if (Settings.General.MERGE_REPLACE_WALL) {
|
||||||
final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING;
|
final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING;
|
||||||
for (PlotId id : plotIds) {
|
for (PlotId id : plotIds) {
|
||||||
setWallFilling(id, wallBlock);
|
setWallFilling(id, wallBlock.toPattern());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -430,7 +433,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||||
for (PlotId id : plotIds) {
|
for (PlotId id : plotIds) {
|
||||||
setWall(id, claim);
|
setWall(id, claim.toPattern());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true; // return false if unlink has been denied
|
return true; // return false if unlink has been denied
|
||||||
@ -447,7 +450,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
@Override public boolean claimPlot(Plot plot) {
|
@Override public boolean claimPlot(Plot plot) {
|
||||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||||
return setWall(plot.getId(), claim);
|
return setWall(plot.getId(), claim.toPattern());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,9 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -18,17 +21,17 @@ import java.util.Locale;
|
|||||||
public int ROAD_HEIGHT = 62;
|
public int ROAD_HEIGHT = 62;
|
||||||
public int PLOT_HEIGHT = 62;
|
public int PLOT_HEIGHT = 62;
|
||||||
public int WALL_HEIGHT = 62;
|
public int WALL_HEIGHT = 62;
|
||||||
public BlockBucket MAIN_BLOCK = BlockBucket.withSingle(BlockUtil.get("stone"));
|
public BlockBucket MAIN_BLOCK = new BlockBucket(BlockTypes.STONE);
|
||||||
// new BlockState[] {BlockUtil.get("stone")};
|
// new BlockState[] {BlockUtil.get("stone")};
|
||||||
public BlockBucket TOP_BLOCK = BlockBucket.withSingle(BlockUtil.get("grass_block"));
|
public BlockBucket TOP_BLOCK = new BlockBucket(BlockTypes.GRASS_BLOCK);
|
||||||
//new BlockState[] {BlockUtil.get("grass")};
|
//new BlockState[] {BlockUtil.get("grass")};
|
||||||
public BlockBucket WALL_BLOCK = BlockBucket.withSingle(BlockUtil.get("stone_slab"));
|
public BlockBucket WALL_BLOCK = new BlockBucket(BlockTypes.STONE_SLAB);
|
||||||
// BlockUtil.get((short) 44, (byte) 0);
|
// BlockUtil.get((short) 44, (byte) 0);
|
||||||
public BlockBucket CLAIMED_WALL_BLOCK = BlockBucket.withSingle(BlockUtil.get("sandstone_slab"));
|
public BlockBucket CLAIMED_WALL_BLOCK = new BlockBucket(BlockTypes.SANDSTONE_SLAB);
|
||||||
// BlockUtil.get((short) 44, (byte) 1);
|
// BlockUtil.get((short) 44, (byte) 1);
|
||||||
public BlockBucket WALL_FILLING = BlockBucket.withSingle(BlockUtil.get("stone"));
|
public BlockBucket WALL_FILLING = new BlockBucket(BlockTypes.STONE);
|
||||||
//BlockUtil.get((short) 1, (byte) 0);
|
//BlockUtil.get((short) 1, (byte) 0);
|
||||||
public BlockBucket ROAD_BLOCK = BlockBucket.withSingle(BlockUtil.get("quartz_block"));
|
public BlockBucket ROAD_BLOCK = new BlockBucket(BlockTypes.QUARTZ_BLOCK);
|
||||||
// BlockUtil.get((short) 155, (byte) 0);
|
// BlockUtil.get((short) 155, (byte) 0);
|
||||||
public boolean PLOT_BEDROCK = true;
|
public boolean PLOT_BEDROCK = true;
|
||||||
|
|
||||||
@ -81,16 +84,16 @@ import java.util.Locale;
|
|||||||
super.loadConfiguration(config);
|
super.loadConfiguration(config);
|
||||||
this.PLOT_BEDROCK = config.getBoolean("plot.bedrock");
|
this.PLOT_BEDROCK = config.getBoolean("plot.bedrock");
|
||||||
this.PLOT_HEIGHT = Math.min(255, config.getInt("plot.height"));
|
this.PLOT_HEIGHT = Math.min(255, config.getInt("plot.height"));
|
||||||
this.MAIN_BLOCK = Configuration.BLOCK_BUCKET.parseString(config.getString("plot.filling"));
|
this.MAIN_BLOCK = new BlockBucket(config.getString("plot.filling"));
|
||||||
this.TOP_BLOCK = Configuration.BLOCK_BUCKET.parseString(config.getString("plot.floor"));
|
this.TOP_BLOCK = new BlockBucket(config.getString("plot.floor"));
|
||||||
this.WALL_BLOCK = Configuration.BLOCK_BUCKET.parseString(config.getString("wall.block"));
|
this.WALL_BLOCK = new BlockBucket(config.getString("wall.block"));
|
||||||
this.ROAD_HEIGHT = Math.min(255, config.getInt("road.height"));
|
this.ROAD_HEIGHT = Math.min(255, config.getInt("road.height"));
|
||||||
this.ROAD_BLOCK = Configuration.BLOCK_BUCKET.parseString(config.getString("road.block"));
|
this.ROAD_BLOCK = new BlockBucket(config.getString("road.block"));
|
||||||
this.WALL_FILLING =
|
this.WALL_FILLING =
|
||||||
Configuration.BLOCK_BUCKET.parseString(config.getString("wall.filling"));
|
new BlockBucket(config.getString("wall.filling"));
|
||||||
this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height"));
|
this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height"));
|
||||||
this.CLAIMED_WALL_BLOCK =
|
this.CLAIMED_WALL_BLOCK =
|
||||||
Configuration.BLOCK_BUCKET.parseString(config.getString("wall.block_claimed"));
|
new BlockBucket(config.getString("wall.block_claimed"));
|
||||||
|
|
||||||
// Dump world settings
|
// Dump world settings
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
|
@ -2,14 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class HybridGen extends IndependentPlotGenerator {
|
public class HybridGen extends IndependentPlotGenerator {
|
||||||
|
|
||||||
@ -35,37 +34,6 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public BlockBucket[][] generateBlockBucketChunk(PlotArea settings) {
|
|
||||||
BlockBucket[][] blockBuckets = new BlockBucket[16][];
|
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
|
||||||
// Bedrock
|
|
||||||
if (hpw.PLOT_BEDROCK) {
|
|
||||||
for (short x = 0; x < 16; x++) {
|
|
||||||
for (short z = 0; z < 16; z++) {
|
|
||||||
blockBuckets[0][(z << 4) | x] =
|
|
||||||
BlockBucket.withSingle(BlockUtil.get("bedrock"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (short x = 0; x < 16; x++) {
|
|
||||||
for (short z = 0; z < 16; z++) {
|
|
||||||
for (int y = 1; y < hpw.PLOT_HEIGHT; y++) {
|
|
||||||
int layer = y >> 4;
|
|
||||||
if (blockBuckets[layer] == null) {
|
|
||||||
blockBuckets[layer] = new BlockBucket[4096];
|
|
||||||
}
|
|
||||||
blockBuckets[layer][((y & 0xF) << 8) | (z << 4) | x] = hpw.MAIN_BLOCK;
|
|
||||||
}
|
|
||||||
int layer = hpw.PLOT_HEIGHT >> 4;
|
|
||||||
if (blockBuckets[layer] == null) {
|
|
||||||
blockBuckets[layer] = new BlockBucket[4096];
|
|
||||||
}
|
|
||||||
blockBuckets[layer][((hpw.PLOT_HEIGHT & 0xF) << 8) | (z << 4) | x] = hpw.MAIN_BLOCK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return blockBuckets;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
@Override public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||||
// Biome
|
// Biome
|
||||||
@ -74,7 +42,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
if (hpw.PLOT_BEDROCK) {
|
if (hpw.PLOT_BEDROCK) {
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
result.setBlock(x, 0, z, BlockUtil.get("bedrock"));
|
result.setBlock(x, 0, z, BlockTypes.BEDROCK.getDefaultState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,7 +96,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
// Road
|
// Road
|
||||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.getBlock());
|
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||||
@ -139,7 +107,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
if (gz[z]) {
|
if (gz[z]) {
|
||||||
// road
|
// road
|
||||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.getBlock());
|
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||||
@ -147,10 +115,10 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
} else {
|
} else {
|
||||||
// wall
|
// wall
|
||||||
for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.WALL_FILLING.getBlock());
|
result.setBlock(x, y, z, hpw.WALL_FILLING.toPattern());
|
||||||
}
|
}
|
||||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK.getBlock());
|
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK.toPattern());
|
||||||
} else {
|
} else {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||||
}
|
}
|
||||||
@ -161,7 +129,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
if (gz[z]) {
|
if (gz[z]) {
|
||||||
// road
|
// road
|
||||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.getBlock());
|
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||||
@ -169,19 +137,19 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
} else if (wz[z]) {
|
} else if (wz[z]) {
|
||||||
// wall
|
// wall
|
||||||
for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.WALL_FILLING.getBlock());
|
result.setBlock(x, y, z, hpw.WALL_FILLING.toPattern());
|
||||||
}
|
}
|
||||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK.getBlock());
|
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK.toPattern());
|
||||||
} else {
|
} else {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// plot
|
// plot
|
||||||
for (int y = 1; y < hpw.PLOT_HEIGHT; y++) {
|
for (int y = 1; y < hpw.PLOT_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.MAIN_BLOCK.getBlock());
|
result.setBlock(x, y, z, hpw.MAIN_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
result.setBlock(x, hpw.PLOT_HEIGHT, z, hpw.TOP_BLOCK.getBlock());
|
result.setBlock(x, hpw.PLOT_HEIGHT, z, hpw.TOP_BLOCK.toPattern());
|
||||||
if (hpw.PLOT_SCHEMATIC) {
|
if (hpw.PLOT_SCHEMATIC) {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, false);
|
placeSchem(hpw, result, rx[x], rz[z], x, z, false);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.Template;
|
import com.github.intellectualsites.plotsquared.plot.commands.Template;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
|
import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
|
||||||
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;
|
||||||
@ -12,10 +11,12 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
|
||||||
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 com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -173,8 +174,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
final boolean canRegen =
|
final boolean canRegen =
|
||||||
(hybridPlotWorld.TYPE == 0) && (hybridPlotWorld.TERRAIN == 0) && REGENERATIVE_CLEAR;
|
(hybridPlotWorld.TYPE == 0) && (hybridPlotWorld.TERRAIN == 0) && REGENERATIVE_CLEAR;
|
||||||
// The component blocks
|
// The component blocks
|
||||||
final BlockBucket plotfloor = hybridPlotWorld.TOP_BLOCK;
|
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
|
||||||
final BlockBucket filling = hybridPlotWorld.MAIN_BLOCK;
|
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
|
||||||
final BlockState bedrock;
|
final BlockState bedrock;
|
||||||
if (hybridPlotWorld.PLOT_BEDROCK) {
|
if (hybridPlotWorld.PLOT_BEDROCK) {
|
||||||
bedrock = BlockUtil.get((short) 7, (byte) 0);
|
bedrock = BlockUtil.get((short) 7, (byte) 0);
|
||||||
@ -182,7 +183,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
bedrock = BlockUtil.get((short) 0, (byte) 0);
|
bedrock = BlockUtil.get((short) 0, (byte) 0);
|
||||||
}
|
}
|
||||||
final BlockState air = BlockUtil.get((short) 0, (byte) 0);
|
final BlockState air = BlockUtil.get((short) 0, (byte) 0);
|
||||||
final String biome = hybridPlotWorld.PLOT_BIOME;
|
final BiomeType biome = hybridPlotWorld.PLOT_BIOME;
|
||||||
final LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
final LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
||||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||||
@Override public void run(int[] value) {
|
@Override public void run(int[] value) {
|
||||||
|
@ -10,21 +10,26 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.block.ChunkBlockQueue;
|
||||||
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 com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
@ -46,8 +51,190 @@ public abstract class HybridUtils {
|
|||||||
public static PlotArea area;
|
public static PlotArea area;
|
||||||
public static boolean UPDATE = false;
|
public static boolean UPDATE = false;
|
||||||
|
|
||||||
public abstract void analyzeRegion(String world, CuboidRegion region,
|
public void analyzeRegion(final String world, final CuboidRegion region, final RunnableVal<PlotAnalysis> whenDone) {
|
||||||
RunnableVal<PlotAnalysis> whenDone);
|
// int diff, int variety, int vertices, int rotation, int height_sd
|
||||||
|
/*
|
||||||
|
* diff: compare to base by looping through all blocks
|
||||||
|
* variety: add to HashSet for each BlockState
|
||||||
|
* height_sd: loop over all blocks and get top block
|
||||||
|
*
|
||||||
|
* vertices: store air map and compare with neighbours
|
||||||
|
* for each block check the adjacent
|
||||||
|
* - Store all blocks then go through in second loop
|
||||||
|
* - recheck each block
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
TaskManager.runTaskAsync(() -> {
|
||||||
|
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||||
|
|
||||||
|
final BlockVector3 bot = region.getMinimumPoint();
|
||||||
|
final BlockVector3 top = region.getMaximumPoint();
|
||||||
|
|
||||||
|
final int bx = bot.getX();
|
||||||
|
final int bz = bot.getZ();
|
||||||
|
final int tx = top.getX();
|
||||||
|
final int tz = top.getZ();
|
||||||
|
final int cbx = bx >> 4;
|
||||||
|
final int cbz = bz >> 4;
|
||||||
|
final int ctx = tx >> 4;
|
||||||
|
final int ctz = tz >> 4;
|
||||||
|
MainUtil.initCache();
|
||||||
|
final int width = tx - bx + 1;
|
||||||
|
final int length = tz - bz + 1;
|
||||||
|
|
||||||
|
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
||||||
|
|
||||||
|
if (!(area instanceof HybridPlotWorld)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HybridPlotWorld hpw = (HybridPlotWorld) area;
|
||||||
|
ChunkBlockQueue chunk = new ChunkBlockQueue(bot, top, false);
|
||||||
|
hpw.getGenerator().generateChunk(chunk, hpw);
|
||||||
|
|
||||||
|
final BlockState[][][] oldBlocks = chunk.getBlocks();
|
||||||
|
final BlockState[][][] newBlocks = new BlockState[256][width][length];
|
||||||
|
final BlockState airBlock = BlockTypes.AIR.getDefaultState();
|
||||||
|
|
||||||
|
System.gc();
|
||||||
|
System.gc();
|
||||||
|
|
||||||
|
final Runnable run = () -> TaskManager.runTaskAsync(() -> {
|
||||||
|
int size = width * length;
|
||||||
|
int[] changes = new int[size];
|
||||||
|
int[] faces = new int[size];
|
||||||
|
int[] data = new int[size];
|
||||||
|
int[] air = new int[size];
|
||||||
|
int[] variety = new int[size];
|
||||||
|
int i = 0;
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
for (int z = 0; z < length; z++) {
|
||||||
|
Set<BlockType> types = new HashSet<>();
|
||||||
|
for (int y = 0; y < 256; y++) {
|
||||||
|
BlockState old = oldBlocks[y][x][z];
|
||||||
|
try {
|
||||||
|
if (old == null) {
|
||||||
|
old = airBlock;
|
||||||
|
}
|
||||||
|
BlockState now = newBlocks[y][x][z];
|
||||||
|
if (!old.equals(now)) {
|
||||||
|
changes[i]++;
|
||||||
|
}
|
||||||
|
if (now.getBlockType().getMaterial().isAir()) {
|
||||||
|
air[i]++;
|
||||||
|
} else {
|
||||||
|
// check vertices
|
||||||
|
// modifications_adjacent
|
||||||
|
if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1
|
||||||
|
&& y < 255) {
|
||||||
|
if (newBlocks[y - 1][x][z].getBlockType().getMaterial().isAir()) {
|
||||||
|
faces[i]++;
|
||||||
|
}
|
||||||
|
if (newBlocks[y][x - 1][z].getBlockType().getMaterial().isAir()) {
|
||||||
|
faces[i]++;
|
||||||
|
}
|
||||||
|
if (newBlocks[y][x][z - 1].getBlockType().getMaterial().isAir()) {
|
||||||
|
faces[i]++;
|
||||||
|
}
|
||||||
|
if (newBlocks[y + 1][x][z].getBlockType().getMaterial().isAir()) {
|
||||||
|
faces[i]++;
|
||||||
|
}
|
||||||
|
if (newBlocks[y][x + 1][z].getBlockType().getMaterial().isAir()) {
|
||||||
|
faces[i]++;
|
||||||
|
}
|
||||||
|
if (newBlocks[y][x][z + 1].getBlockType().getMaterial().isAir()) {
|
||||||
|
faces[i]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!now.equals(now.getBlockType().getDefaultState())) {
|
||||||
|
data[i]++;
|
||||||
|
}
|
||||||
|
types.add(now.getBlockType());
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
variety[i] = types.size();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// analyze plot
|
||||||
|
// put in analysis obj
|
||||||
|
|
||||||
|
// run whenDone
|
||||||
|
PlotAnalysis analysis = new PlotAnalysis();
|
||||||
|
analysis.changes = (int) (MathMan.getMean(changes) * 100);
|
||||||
|
analysis.faces = (int) (MathMan.getMean(faces) * 100);
|
||||||
|
analysis.data = (int) (MathMan.getMean(data) * 100);
|
||||||
|
analysis.air = (int) (MathMan.getMean(air) * 100);
|
||||||
|
analysis.variety = (int) (MathMan.getMean(variety) * 100);
|
||||||
|
|
||||||
|
analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes) * 100);
|
||||||
|
analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces) * 100);
|
||||||
|
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data) * 100);
|
||||||
|
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air) * 100);
|
||||||
|
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety) * 100);
|
||||||
|
System.gc();
|
||||||
|
System.gc();
|
||||||
|
whenDone.value = analysis;
|
||||||
|
whenDone.run();
|
||||||
|
});
|
||||||
|
System.gc();
|
||||||
|
MainUtil.initCache();
|
||||||
|
Location botLoc = new Location(world, bot.getX(), bot.getY(), bot.getZ());
|
||||||
|
Location topLoc = new Location(world, top.getX(), top.getY(), top.getZ());
|
||||||
|
ChunkManager.chunkTask(botLoc, topLoc, new RunnableVal<int[]>() {
|
||||||
|
@Override public void run(int[] value) {
|
||||||
|
int X = value[0];
|
||||||
|
int Z = value[1];
|
||||||
|
int minX;
|
||||||
|
if (X == cbx) {
|
||||||
|
minX = bx & 15;
|
||||||
|
} else {
|
||||||
|
minX = 0;
|
||||||
|
}
|
||||||
|
int minZ;
|
||||||
|
if (Z == cbz) {
|
||||||
|
minZ = bz & 15;
|
||||||
|
} else {
|
||||||
|
minZ = 0;
|
||||||
|
}
|
||||||
|
int maxX;
|
||||||
|
if (X == ctx) {
|
||||||
|
maxX = tx & 15;
|
||||||
|
} else {
|
||||||
|
maxX = 16;
|
||||||
|
}
|
||||||
|
int maxZ;
|
||||||
|
if (Z == ctz) {
|
||||||
|
maxZ = tz & 15;
|
||||||
|
} else {
|
||||||
|
maxZ = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cbx = X << 4;
|
||||||
|
int cbz = Z << 4;
|
||||||
|
|
||||||
|
int xb = cbx - bx;
|
||||||
|
int zb = cbz - bz;
|
||||||
|
for (int x = minX; x <= maxX; x++) {
|
||||||
|
int xx = cbx + x;
|
||||||
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
|
int zz = cbz + z;
|
||||||
|
for (int y = 0; y < 256; y++) {
|
||||||
|
BlockState block = queue.getBlock(xx, y, zz);
|
||||||
|
int xr = xb + x;
|
||||||
|
int zr = zb + z;
|
||||||
|
newBlocks[y][xr][zr] = block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, () -> TaskManager.runTaskAsync(run), 5);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void analyzePlot(final Plot origin, final RunnableVal<PlotAnalysis> whenDone) {
|
public void analyzePlot(final Plot origin, final RunnableVal<PlotAnalysis> whenDone) {
|
||||||
final ArrayDeque<CuboidRegion> zones = new ArrayDeque<>(origin.getRegions());
|
final ArrayDeque<CuboidRegion> zones = new ArrayDeque<>(origin.getRegions());
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.generator;
|
package com.github.intellectualsites.plotsquared.plot.generator;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
|
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
|
||||||
@ -19,14 +18,6 @@ public abstract class IndependentPlotGenerator {
|
|||||||
*/
|
*/
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a 16x4096 array of BlockBuckets corresponding to the area settings to allow for plot analysis
|
|
||||||
*
|
|
||||||
* @param settings
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract BlockBucket[][] generateBlockBucketChunk(PlotArea settings);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the setBlock or setBiome method of the PlotChunk result parameter to make changes.
|
* Use the setBlock or setBiome method of the PlotChunk result parameter to make changes.
|
||||||
* The PlotArea settings is the same one this was initialized with.
|
* The PlotArea settings is the same one this was initialized with.
|
||||||
|
@ -6,12 +6,11 @@ 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.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.ItemUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.ItemUtil;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package com.github.intellectualsites.plotsquared.plot.listener;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
@ -12,6 +11,7 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
import com.sk89q.worldedit.extent.NullExtent;
|
import com.sk89q.worldedit.extent.NullExtent;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
@ -19,7 +19,6 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.listener;
|
package com.github.intellectualsites.plotsquared.plot.listener;
|
||||||
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
@ -8,6 +7,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
|||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
@ -15,7 +15,6 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class WEExtent extends AbstractDelegateExtent {
|
public class WEExtent extends AbstractDelegateExtent {
|
||||||
|
@ -5,7 +5,6 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -13,12 +12,12 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
import com.sk89q.worldedit.extent.NullExtent;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class WESubscriber {
|
public class WESubscriber {
|
||||||
|
@ -2,44 +2,56 @@ package com.github.intellectualsites.plotsquared.plot.object;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.configuration.serialization.ConfigurationSerializable;
|
import com.github.intellectualsites.plotsquared.configuration.serialization.ConfigurationSerializable;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.collection.RandomCollection;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.PatternUtil;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.regex.Matcher;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A block bucket is a container of block types, where each block
|
* A block bucket is a container of block types, where each block
|
||||||
* has a specified chance of being randomly picked
|
* has a specified chance of being randomly picked
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(of={"blocks"}) @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket
|
@EqualsAndHashCode(of={"input"}) @SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
implements Iterable<BlockState>, ConfigurationSerializable {
|
public final class BlockBucket implements ConfigurationSerializable {
|
||||||
|
private boolean compiled;
|
||||||
|
|
||||||
private final Random random = new Random();
|
private StringBuilder input;
|
||||||
private final Map<BlockState, Double> blocks;
|
|
||||||
|
|
||||||
private final BucketIterator bucketIterator = new BucketIterator();
|
|
||||||
private boolean compiled, singleItem;
|
|
||||||
private BlockState head;
|
|
||||||
|
|
||||||
private RandomCollection<BlockState> randomBlocks;
|
|
||||||
private BlockState single;
|
private BlockState single;
|
||||||
|
private Pattern pattern;
|
||||||
|
|
||||||
|
public BlockBucket(BlockType type) {
|
||||||
|
this(type.getId());
|
||||||
|
this.single = type.getDefaultState();
|
||||||
|
this.pattern = new BlockPattern(this.single);
|
||||||
|
this.compiled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockBucket(BlockState state) {
|
||||||
|
this(state.getAsString());
|
||||||
|
this.single = state;
|
||||||
|
this.pattern = new BlockPattern(this.single);
|
||||||
|
this.compiled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockBucket(String input) {
|
||||||
|
this.input = new StringBuilder(input);
|
||||||
|
}
|
||||||
|
|
||||||
public BlockBucket() {
|
public BlockBucket() {
|
||||||
this.blocks = new HashMap<>();
|
this.input = new StringBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockBucket withSingle(@NonNull final BlockState block) {
|
public static BlockBucket withSingle(@NonNull final BlockState block) {
|
||||||
@ -64,139 +76,75 @@ import java.util.Random;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addBlock(@NonNull final BlockState block, double chance) {
|
private void addBlock(@NonNull final BlockState block, double chance) {
|
||||||
if (chance == -1)
|
if (chance == -1) chance = 1;
|
||||||
chance = 1;
|
String prefix = input.length() == 0 ? "" : ",";
|
||||||
this.blocks.put(block, chance);
|
input.append(prefix).append(chance + "%" + prefix);
|
||||||
this.compiled = false;
|
this.compiled = false;
|
||||||
if (head == null) {
|
|
||||||
head = block;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return blocks.isEmpty();
|
return input == null || input.length() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static java.util.regex.Pattern regex = java.util.regex.Pattern.compile("((?<namespace>[A-Za-z_]+):)?(?<block>([A-Za-z_]+(\\[?[\\S\\s]+\\])?))(:(?<chance>[0-9]{1,3}))?");
|
||||||
* Get all blocks that are configured in the bucket
|
|
||||||
*
|
|
||||||
* @return Immutable collection containing all blocks that can
|
|
||||||
* be found in the bucket
|
|
||||||
*/
|
|
||||||
public Collection<BlockState> getBlocks() {
|
|
||||||
if (!isCompiled()) {
|
|
||||||
this.compile();
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableCollection(this.blocks.keySet());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a collection containing a specified amount of randomly selected blocks
|
|
||||||
*
|
|
||||||
* @param count Number of blocks
|
|
||||||
* @return Immutable collection containing randomly selected blocks
|
|
||||||
*/
|
|
||||||
public Collection<BlockState> getBlocks(final int count) {
|
|
||||||
return Arrays.asList(getBlockArray(count));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an array containing a specified amount of randomly selected blocks
|
|
||||||
*
|
|
||||||
* @param count Number of blocks
|
|
||||||
* @return Immutable collection containing randomly selected blocks
|
|
||||||
*/
|
|
||||||
public BlockState[] getBlockArray(final int count) {
|
|
||||||
final BlockState[] blocks = new BlockState[count];
|
|
||||||
if (this.singleItem) {
|
|
||||||
Arrays.fill(blocks, 0, count, getBlock());
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
blocks[i] = getBlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return blocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSingleItem() {
|
|
||||||
return this.singleItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void compile() {
|
public void compile() {
|
||||||
if (isCompiled()) {
|
if (isCompiled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.compiled = true;
|
this.compiled = true;
|
||||||
switch (blocks.size()) {
|
String string = this.input.toString();
|
||||||
case 0:
|
if (string.isEmpty()) {
|
||||||
single = null;
|
this.single = null;
|
||||||
this.randomBlocks = null;
|
this.pattern = null;
|
||||||
break;
|
return;
|
||||||
case 1:
|
|
||||||
single = blocks.keySet().iterator().next();
|
|
||||||
this.randomBlocks = null;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
single = null;
|
|
||||||
this.randomBlocks = RandomCollection.of(blocks, random);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
// Convert legacy format
|
||||||
|
boolean legacy = false;
|
||||||
@NotNull @Override public Iterator<BlockState> iterator() {
|
String[] blocksStr = string.split(",(?![^\\(\\[]*[\\]\\)])");
|
||||||
return this.bucketIterator;
|
if (blocksStr.length == 1) {
|
||||||
|
try {
|
||||||
|
this.single = BlockUtil.get(string);
|
||||||
|
this.pattern = new BlockPattern(single);
|
||||||
|
return;
|
||||||
|
} catch (Exception ignore) {}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < blocksStr.length; i++) {
|
||||||
|
String entry = blocksStr[i];
|
||||||
|
Matcher matcher = regex.matcher(entry);
|
||||||
|
if (matcher.find()) {
|
||||||
|
String chanceStr = matcher.group("chance");
|
||||||
|
if (chanceStr != null && MathMan.isInteger(chanceStr)) {
|
||||||
|
String[] parts = entry.split(":");
|
||||||
|
parts = Arrays.copyOf(parts, parts.length - 1);
|
||||||
|
entry = chanceStr + "%" + StringMan.join(parts, ":");
|
||||||
|
blocksStr[i] = entry;
|
||||||
|
legacy = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (legacy) {
|
||||||
|
string = StringMan.join(blocksStr, ",");
|
||||||
|
}
|
||||||
|
pattern = PatternUtil.parse(null, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompiled() {
|
public boolean isCompiled() {
|
||||||
return this.compiled;
|
return this.compiled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Pattern toPattern() {
|
||||||
* Get a random block out of the bucket
|
this.compile();
|
||||||
*
|
return this.pattern;
|
||||||
* @return Randomly picked block (cased on specified rates)
|
|
||||||
*/
|
|
||||||
public BlockState getBlock() {
|
|
||||||
if (!isCompiled()) {
|
|
||||||
this.compile();
|
|
||||||
}
|
|
||||||
if (single != null) {
|
|
||||||
return single;
|
|
||||||
}
|
|
||||||
if (randomBlocks != null) {
|
|
||||||
return randomBlocks.next();
|
|
||||||
}
|
|
||||||
return BlockTypes.AIR.getDefaultState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String toString() {
|
@Override public String toString() {
|
||||||
if (!isCompiled()) {
|
return input.toString();
|
||||||
compile();
|
|
||||||
}
|
|
||||||
if (blocks.size() == 1) {
|
|
||||||
return blocks.entrySet().iterator().next().getKey().toString();
|
|
||||||
}
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
|
||||||
Iterator<Entry<BlockState, Double>> iterator = blocks.entrySet().iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Entry<BlockState, Double> entry = iterator.next();
|
|
||||||
BlockState block = entry.getKey();
|
|
||||||
builder.append(block);
|
|
||||||
Double weight = entry.getValue();
|
|
||||||
if (weight != 1) {
|
|
||||||
builder.append(":").append(weight.intValue());
|
|
||||||
}
|
|
||||||
if (iterator.hasNext()) {
|
|
||||||
builder.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAir() {
|
public boolean isAir() {
|
||||||
compile();
|
compile();
|
||||||
return blocks.isEmpty() || (single != null && single.getBlockType().getMaterial().isAir());
|
return isEmpty() || (single != null && single.getBlockType().getMaterial().isAir());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Map<String, Object> serialize() {
|
@Override public Map<String, Object> serialize() {
|
||||||
@ -220,16 +168,4 @@ import java.util.Random;
|
|||||||
return num <= max && num >= min;
|
return num <= max && num >= min;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final class BucketIterator implements Iterator<BlockState> {
|
|
||||||
|
|
||||||
@Override public boolean hasNext() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public BlockState next() {
|
|
||||||
return getBlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
|
@ -22,7 +22,6 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
|
||||||
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 com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
@ -31,9 +30,12 @@ import com.google.common.collect.BiMap;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -921,7 +923,7 @@ public class Plot {
|
|||||||
* @param biome The biome e.g. "forest"
|
* @param biome The biome e.g. "forest"
|
||||||
* @param whenDone The task to run when finished, or null
|
* @param whenDone The task to run when finished, or null
|
||||||
*/
|
*/
|
||||||
public void setBiome(final String biome, final Runnable whenDone) {
|
public void setBiome(final BiomeType biome, final Runnable whenDone) {
|
||||||
final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions());
|
final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions());
|
||||||
final int extendBiome;
|
final int extendBiome;
|
||||||
if (area instanceof SquarePlotWorld) {
|
if (area instanceof SquarePlotWorld) {
|
||||||
@ -1459,7 +1461,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
Location location = manager.getSignLoc(this);
|
Location location = manager.getSignLoc(this);
|
||||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
|
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
|
||||||
queue.setBlock(location.getX(), location.getY(), location.getZ(), BlockUtil.get("air"));
|
queue.setBlock(location.getX(), location.getY(), location.getZ(), BlockTypes.AIR.getDefaultState());
|
||||||
queue.flush();
|
queue.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,9 +1590,13 @@ public class Plot {
|
|||||||
* Sets components such as border, wall, floor.
|
* Sets components such as border, wall, floor.
|
||||||
* (components are generator specific)
|
* (components are generator specific)
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean setComponent(String component, String blocks) {
|
public boolean setComponent(String component, String blocks) {
|
||||||
BlockBucket parsed = Configuration.BLOCK_BUCKET.parseString(blocks);
|
BlockBucket parsed = Configuration.BLOCK_BUCKET.parseString(blocks);
|
||||||
return !(parsed == null || parsed.isEmpty()) && this.setComponent(component, parsed);
|
if (parsed != null && parsed.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.setComponent(component, parsed.toPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1598,7 +1604,7 @@ public class Plot {
|
|||||||
*
|
*
|
||||||
* @return the name of the biome
|
* @return the name of the biome
|
||||||
*/
|
*/
|
||||||
public String getBiome() {
|
public BiomeType getBiome() {
|
||||||
Location location = this.getCenter();
|
Location location = this.getCenter();
|
||||||
return WorldUtil.IMP.getBiome(location.getWorld(), location.getX(), location.getZ());
|
return WorldUtil.IMP.getBiome(location.getWorld(), location.getX(), location.getZ());
|
||||||
}
|
}
|
||||||
@ -2718,7 +2724,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockVector3 pos1 = BlockVector3.at(gbotabs.getX() + 1, 0, gbotabs.getZ());
|
BlockVector3 pos1 = BlockVector3.at(gbotabs.getX(), 0, gbotabs.getZ());
|
||||||
BlockVector3 pos2 = BlockVector3.at(gtopabs.getX(), Plot.MAX_HEIGHT - 1, gtopabs.getZ());
|
BlockVector3 pos2 = BlockVector3.at(gtopabs.getX(), Plot.MAX_HEIGHT - 1, gtopabs.getZ());
|
||||||
regions.add(
|
regions.add(
|
||||||
new CuboidRegion(pos1, pos2));
|
new CuboidRegion(pos1, pos2));
|
||||||
@ -2856,7 +2862,7 @@ public class Plot {
|
|||||||
* @param blocks
|
* @param blocks
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setComponent(String component, BlockBucket blocks) {
|
public boolean setComponent(String component, Pattern blocks) {
|
||||||
if (StringMan
|
if (StringMan
|
||||||
.isEqualToAny(component, getManager().getPlotComponents(this.getId()))) {
|
.isEqualToAny(component, getManager().getPlotComponents(this.getId()))) {
|
||||||
EventUtil.manager.callComponentSet(this, component);
|
EventUtil.manager.callComponentSet(this, component);
|
||||||
|
@ -25,6 +25,8 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -54,14 +56,13 @@ public abstract class PlotArea {
|
|||||||
private final PlotId min;
|
private final PlotId min;
|
||||||
private final PlotId max;
|
private final PlotId max;
|
||||||
@NotNull private final IndependentPlotGenerator generator;
|
@NotNull private final IndependentPlotGenerator generator;
|
||||||
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;
|
||||||
public boolean MISC_SPAWN_UNOWNED = false;
|
public boolean MISC_SPAWN_UNOWNED = false;
|
||||||
public boolean MOB_SPAWNING = false;
|
public boolean MOB_SPAWNING = false;
|
||||||
public boolean MOB_SPAWNER_SPAWNING = false;
|
public boolean MOB_SPAWNER_SPAWNING = false;
|
||||||
public String PLOT_BIOME = "FOREST";
|
public BiomeType PLOT_BIOME = BiomeTypes.FOREST;
|
||||||
public boolean PLOT_CHAT = false;
|
public boolean PLOT_CHAT = false;
|
||||||
public boolean SCHEMATIC_CLAIM_SPECIFY = false;
|
public boolean SCHEMATIC_CLAIM_SPECIFY = false;
|
||||||
public boolean SCHEMATIC_ON_CLAIM = false;
|
public boolean SCHEMATIC_ON_CLAIM = false;
|
||||||
@ -106,11 +107,6 @@ public abstract class PlotArea {
|
|||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
this.worldhash = worldName.hashCode();
|
this.worldhash = worldName.hashCode();
|
||||||
if (Settings.Enabled_Components.PLOT_EXPIRY) {
|
|
||||||
blockBucketChunk = generator.generateBlockBucketChunk(this);
|
|
||||||
} else {
|
|
||||||
blockBucketChunk = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull protected abstract PlotManager createManager();
|
@NotNull protected abstract PlotManager createManager();
|
||||||
@ -119,18 +115,6 @@ 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;
|
|
||||||
}
|
|
||||||
return generator.generateBlockBucketChunk(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the region for this PlotArea or a CuboidRegion encompassing
|
* Returns the region for this PlotArea or a CuboidRegion encompassing
|
||||||
* the whole world if none exists.
|
* the whole world if none exists.
|
||||||
|
@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.object;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.Template;
|
import com.github.intellectualsites.plotsquared.plot.commands.Template;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -53,7 +54,7 @@ public abstract class PlotManager {
|
|||||||
*/
|
*/
|
||||||
public abstract String[] getPlotComponents(PlotId plotId);
|
public abstract String[] getPlotComponents(PlotId plotId);
|
||||||
|
|
||||||
public abstract boolean setComponent(PlotId plotId, String component, BlockBucket blocks);
|
public abstract boolean setComponent(PlotId plotId, String component, Pattern blocks);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PLOT MERGING (return false if your generator does not support plot
|
* PLOT MERGING (return false if your generator does not support plot
|
||||||
|
@ -2,9 +2,9 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
|
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -10,7 +10,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -2,9 +2,9 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ArrayUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.ArrayUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
|
||||||
public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||||
private final SinglePlotArea[] array;
|
private final SinglePlotArea[] array;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
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.PlotArea;
|
||||||
@ -10,6 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -69,7 +69,7 @@ public class SinglePlotManager extends PlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setComponent(PlotId plotId, String component,
|
@Override public boolean setComponent(PlotId plotId, String component,
|
||||||
BlockBucket blocks) {
|
Pattern blocks) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
|
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class SingleWorldGenerator extends IndependentPlotGenerator {
|
public class SingleWorldGenerator extends IndependentPlotGenerator {
|
||||||
private Location bedrock1 = new Location(null, 0, 0, 0);
|
private Location bedrock1 = new Location(null, 0, 0, 0);
|
||||||
@ -21,64 +21,19 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
|
|||||||
return "PlotSquared:single";
|
return "PlotSquared:single";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public BlockBucket[][] generateBlockBucketChunk(PlotArea settings) {
|
|
||||||
BlockBucket[][] blockBuckets = new BlockBucket[16][];
|
|
||||||
SinglePlotArea area = (SinglePlotArea) settings;
|
|
||||||
if (area.VOID) {
|
|
||||||
return blockBuckets;
|
|
||||||
}
|
|
||||||
for (int x = bedrock1.getX(); x <= bedrock2.getX(); x++) {
|
|
||||||
for (int z = bedrock1.getZ(); z <= bedrock2.getZ(); z++) {
|
|
||||||
for (int y = bedrock1.getY(); y <= bedrock2.getY(); y++) {
|
|
||||||
int layer = y >> 4;
|
|
||||||
if (blockBuckets[layer] == null) {
|
|
||||||
blockBuckets[layer] = new BlockBucket[4096];
|
|
||||||
}
|
|
||||||
blockBuckets[layer][((y & 0xF) << 8) | (z << 4) | x] =
|
|
||||||
BlockBucket.withSingle(BlockUtil.get("bedrock"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int x = dirt1.getX(); x <= dirt2.getX(); x++) {
|
|
||||||
for (int z = dirt1.getZ(); z <= dirt2.getZ(); z++) {
|
|
||||||
for (int y = dirt1.getY(); y <= dirt2.getY(); y++) {
|
|
||||||
int layer = y >> 4;
|
|
||||||
if (blockBuckets[layer] == null) {
|
|
||||||
blockBuckets[layer] = new BlockBucket[4096];
|
|
||||||
}
|
|
||||||
blockBuckets[layer][((y & 0xF) << 8) | (z << 4) | x] =
|
|
||||||
BlockBucket.withSingle(BlockUtil.get("dirt"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int x = grass1.getX(); x <= grass2.getX(); x++) {
|
|
||||||
for (int z = grass1.getZ(); z <= grass2.getZ(); z++) {
|
|
||||||
for (int y = grass1.getY(); y <= grass2.getY(); y++) {
|
|
||||||
int layer = y >> 4;
|
|
||||||
if (blockBuckets[layer] == null) {
|
|
||||||
blockBuckets[layer] = new BlockBucket[4096];
|
|
||||||
}
|
|
||||||
blockBuckets[layer][((y & 0xF) << 8) | (z << 4) | x] =
|
|
||||||
BlockBucket.withSingle(BlockUtil.get("grass_block"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return blockBuckets;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
@Override public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
||||||
SinglePlotArea area = (SinglePlotArea) settings;
|
SinglePlotArea area = (SinglePlotArea) settings;
|
||||||
if (area.VOID) {
|
if (area.VOID) {
|
||||||
Location min = result.getMin();
|
Location min = result.getMin();
|
||||||
if (min.getX() == 0 && min.getZ() == 0) {
|
if (min.getX() == 0 && min.getZ() == 0) {
|
||||||
result.setBlock(0, 0, 0, BlockUtil.get("bedrock"));
|
result.setBlock(0, 0, 0, BlockTypes.BEDROCK.getDefaultState());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.setCuboid(bedrock1, bedrock2, BlockUtil.get("bedrock"));
|
result.setCuboid(bedrock1, bedrock2, BlockTypes.BEDROCK.getDefaultState());
|
||||||
result.setCuboid(dirt1, dirt2, BlockUtil.get("dirt"));
|
result.setCuboid(dirt1, dirt2, BlockTypes.DIRT.getDefaultState());
|
||||||
result.setCuboid(grass1, grass2, BlockUtil.get("grass_block"));
|
result.setCuboid(grass1, grass2, BlockTypes.GRASS_BLOCK.getDefaultState());
|
||||||
}
|
}
|
||||||
result.fillBiome("PLAINS");
|
result.fillBiome(BiomeTypes.PLAINS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||||
|
@ -3,12 +3,12 @@ package com.github.intellectualsites.plotsquared.plot.util;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
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.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
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 com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -16,12 +16,13 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.stream.AbstractDelegateOutputStream;
|
import com.github.intellectualsites.plotsquared.plot.object.stream.AbstractDelegateOutputStream;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -46,6 +47,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -217,10 +219,9 @@ public class MainUtil {
|
|||||||
* @return true if any changes were made
|
* @return true if any changes were made
|
||||||
*/
|
*/
|
||||||
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
|
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
|
||||||
String biome = area.PLOT_BIOME;
|
BiomeType biome = area.PLOT_BIOME;
|
||||||
if (!StringMan.isEqual(WorldUtil.IMP
|
if (!Objects.equals(WorldUtil.IMP.getBiome(area.worldname, (pos1.getX() + pos2.getX()) / 2,
|
||||||
.getBiome(area.worldname, (pos1.getX() + pos2.getX()) / 2,
|
(pos1.getZ() + pos2.getZ()) / 2), biome)) {
|
||||||
(pos1.getZ() + pos2.getZ()) / 2), biome)) {
|
|
||||||
MainUtil.setBiome(area.worldname, pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(),
|
MainUtil.setBiome(area.worldname, pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(),
|
||||||
biome);
|
biome);
|
||||||
return true;
|
return true;
|
||||||
@ -567,7 +568,7 @@ public class MainUtil {
|
|||||||
* @param p2z
|
* @param p2z
|
||||||
* @param biome
|
* @param biome
|
||||||
*/
|
*/
|
||||||
public static void setBiome(String world, int p1x, int p1z, int p2x, int p2z, String biome) {
|
public static void setBiome(String world, int p1x, int p1z, int p2x, int p2z, BiomeType biome) {
|
||||||
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3();
|
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3();
|
||||||
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(Plot.MAX_HEIGHT - 1);
|
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(Plot.MAX_HEIGHT - 1);
|
||||||
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
||||||
@ -750,7 +751,7 @@ public class MainUtil {
|
|||||||
int num = plot.getConnectedPlots().size();
|
int num = plot.getConnectedPlots().size();
|
||||||
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : Captions.NONE.getTranslated();
|
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : Captions.NONE.getTranslated();
|
||||||
Location bot = plot.getCorners()[0];
|
Location bot = plot.getCorners()[0];
|
||||||
String biome = WorldUtil.IMP.getBiome(plot.getWorldName(), bot.getX(), bot.getZ());
|
BiomeType biome = WorldUtil.IMP.getBiome(plot.getWorldName(), bot.getX(), bot.getZ());
|
||||||
String trusted = getPlayerList(plot.getTrusted());
|
String trusted = getPlayerList(plot.getTrusted());
|
||||||
String members = getPlayerList(plot.getMembers());
|
String members = getPlayerList(plot.getMembers());
|
||||||
String denied = getPlayerList(plot.getDenied());
|
String denied = getPlayerList(plot.getDenied());
|
||||||
@ -798,7 +799,7 @@ public class MainUtil {
|
|||||||
info = info.replace("%alias%", alias);
|
info = info.replace("%alias%", alias);
|
||||||
info = info.replace("%num%", String.valueOf(num));
|
info = info.replace("%num%", String.valueOf(num));
|
||||||
info = info.replace("%desc%", description);
|
info = info.replace("%desc%", description);
|
||||||
info = info.replace("%biome%", biome);
|
info = info.replace("%biome%", biome.toString().toLowerCase());
|
||||||
info = info.replace("%owner%", owner);
|
info = info.replace("%owner%", owner);
|
||||||
info = info.replace("%members%", members);
|
info = info.replace("%members%", members);
|
||||||
info = info.replace("%player%", player.getName());
|
info = info.replace("%player%", player.getName());
|
||||||
|
@ -10,7 +10,6 @@ import com.github.intellectualsites.plotsquared.plot.generator.ClassicPlotWorld;
|
|||||||
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.PlotArea;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
@ -27,6 +26,7 @@ import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
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.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -13,6 +12,8 @@ import com.sk89q.jnbt.NBTInputStream;
|
|||||||
import com.sk89q.jnbt.NBTOutputStream;
|
import com.sk89q.jnbt.NBTOutputStream;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -32,10 +33,6 @@ import java.util.zip.ZipOutputStream;
|
|||||||
public abstract class WorldUtil {
|
public abstract class WorldUtil {
|
||||||
public static WorldUtil IMP;
|
public static WorldUtil IMP;
|
||||||
|
|
||||||
public abstract int getBiomeFromString(String value);
|
|
||||||
|
|
||||||
public abstract String[] getBiomeList();
|
|
||||||
|
|
||||||
public abstract String getMainWorld();
|
public abstract String getMainWorld();
|
||||||
|
|
||||||
public abstract boolean isWorld(String worldName);
|
public abstract boolean isWorld(String worldName);
|
||||||
@ -56,7 +53,7 @@ public abstract class WorldUtil {
|
|||||||
|
|
||||||
public abstract StringComparison<BlockState>.ComparisonResult getClosestBlock(String name);
|
public abstract StringComparison<BlockState>.ComparisonResult getClosestBlock(String name);
|
||||||
|
|
||||||
public abstract String getBiome(String world, int x, int z);
|
public abstract BiomeType getBiome(String world, int x, int z);
|
||||||
|
|
||||||
public abstract BlockState getBlock(Location location);
|
public abstract BlockState getBlock(Location location);
|
||||||
|
|
||||||
@ -66,7 +63,7 @@ public abstract class WorldUtil {
|
|||||||
|
|
||||||
public abstract void setSign(String world, int x, int y, int z, String[] lines);
|
public abstract void setSign(String world, int x, int y, int z, String[] lines);
|
||||||
|
|
||||||
public abstract void setBiomes(String world, CuboidRegion region, String biome);
|
public abstract void setBiomes(String world, CuboidRegion region, BiomeType biome);
|
||||||
|
|
||||||
public abstract com.sk89q.worldedit.world.World getWeWorld(String world);
|
public abstract com.sk89q.worldedit.world.World getWeWorld(String world);
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.PatternUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -85,6 +88,10 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
|||||||
this.modified = modified;
|
this.modified = modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||||
|
return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
||||||
if ((y > 255) || (y < 0)) {
|
if ((y > 255) || (y < 0)) {
|
||||||
return false;
|
return false;
|
||||||
@ -118,7 +125,7 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
|||||||
return setBlock(x, y, z, id.toBaseBlock());
|
return setBlock(x, y, z, id.toBaseBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public final boolean setBiome(int x, int z, String biome) {
|
@Override public final boolean setBiome(int x, int z, BiomeType biomeType) {
|
||||||
long pair = (long) (x >> 4) << 32 | (z >> 4) & 0xFFFFFFFFL;
|
long pair = (long) (x >> 4) << 32 | (z >> 4) & 0xFFFFFFFFL;
|
||||||
LocalChunk result = this.blockChunks.get(pair);
|
LocalChunk result = this.blockChunks.get(pair);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -131,7 +138,7 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
|||||||
chunks.add(result);
|
chunks.add(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.setBiome(x & 15, z & 15, biome);
|
result.setBiome(x & 15, z & 15, biomeType);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +167,7 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
|||||||
public final int x;
|
public final int x;
|
||||||
|
|
||||||
public BaseBlock[][] baseblocks;
|
public BaseBlock[][] baseblocks;
|
||||||
public String[][] biomes;
|
public BiomeType[][] biomes;
|
||||||
|
|
||||||
public LocalChunk(BasicLocalBlockQueue parent, int x, int z) {
|
public LocalChunk(BasicLocalBlockQueue parent, int x, int z) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
@ -187,15 +194,15 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
|||||||
|
|
||||||
public abstract void setBlock(final int x, final int y, final int z, final BaseBlock block);
|
public abstract void setBlock(final int x, final int y, final int z, final BaseBlock block);
|
||||||
|
|
||||||
public void setBiome(int x, int z, String biome) {
|
public void setBiome(int x, int z, BiomeType biomeType) {
|
||||||
if (this.biomes == null) {
|
if (this.biomes == null) {
|
||||||
this.biomes = new String[16][];
|
this.biomes = new BiomeType[16][];
|
||||||
}
|
}
|
||||||
String[] index = this.biomes[x];
|
BiomeType[] index = this.biomes[x];
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
index = this.biomes[x] = new String[16];
|
index = this.biomes[x] = new BiomeType[16];
|
||||||
}
|
}
|
||||||
index[z] = biome;
|
index[z] = biomeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long longHash() {
|
public long longHash() {
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.util.block;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
||||||
|
|
||||||
|
public final BiomeType[] biomeGrid;
|
||||||
|
public final BlockState[][][] result;
|
||||||
|
private final int width;
|
||||||
|
private final int length;
|
||||||
|
private final int area;
|
||||||
|
private final BlockVector3 bot;
|
||||||
|
private final BlockVector3 top;
|
||||||
|
|
||||||
|
public ChunkBlockQueue(BlockVector3 bot, BlockVector3 top, boolean biomes) {
|
||||||
|
super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15));
|
||||||
|
this.width = top.getX() - bot.getX()+ 1;
|
||||||
|
this.length = top.getZ() - bot.getZ() + 1;
|
||||||
|
this.area = width * length;
|
||||||
|
this.result = new BlockState[256][][];
|
||||||
|
this.biomeGrid = biomes ? new BiomeType[width * length] : null;
|
||||||
|
this.bot = bot;
|
||||||
|
this.top = top;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState[][][] getBlocks() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void fillBiome(BiomeType biomeType) {
|
||||||
|
if (biomeGrid == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Arrays.fill(biomeGrid, biomeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBiome(int x, int z, BiomeType biomeType) {
|
||||||
|
if (this.biomeGrid != null) {
|
||||||
|
biomeGrid[(z * width) + x] = biomeType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, BlockState id) {
|
||||||
|
this.storeCache(x, y, z, id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeCache(final int x, final int y, final int z, final BlockState id) {
|
||||||
|
BlockState[][] resultY = result[y];
|
||||||
|
if (resultY == null) {
|
||||||
|
result[y] = resultY = new BlockState[length][];
|
||||||
|
}
|
||||||
|
BlockState[] resultYZ = resultY[z];
|
||||||
|
if (resultYZ == null) {
|
||||||
|
resultY[z] = resultYZ = new BlockState[width];
|
||||||
|
}
|
||||||
|
resultYZ[x] = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
||||||
|
this.storeCache(x, y, z, id.toImmutableState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public BlockState getBlock(int x, int y, int z) {
|
||||||
|
BlockState[][] blocksY = result[y];
|
||||||
|
if (blocksY != null) {
|
||||||
|
BlockState[] blocksYZ = blocksY[z];
|
||||||
|
if (blocksYZ != null) {
|
||||||
|
return blocksYZ[x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String getWorld() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public Location getMax() {
|
||||||
|
return new Location(getWorld(), top.getX(), top.getY(), top.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public Location getMin() {
|
||||||
|
return new Location(getWorld(), bot.getX(), bot.getY(), bot.getZ());
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util.block;
|
package com.github.intellectualsites.plotsquared.plot.util.block;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
@ -58,6 +60,10 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||||
|
return parent.setBlock(x, y, z, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
||||||
return parent.setBlock(x, y, z, id);
|
return parent.setBlock(x, y, z, id);
|
||||||
}
|
}
|
||||||
@ -70,7 +76,7 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue {
|
|||||||
return parent.getBlock(x, y, z);
|
return parent.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int z, String biome) {
|
@Override public boolean setBiome(int x, int z, BiomeType biome) {
|
||||||
return parent.setBiome(x, z, biome);
|
return parent.setBiome(x, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util.block;
|
package com.github.intellectualsites.plotsquared.plot.util.block;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.world.PatternUtil;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
@ -57,6 +59,10 @@ public abstract class LocalBlockQueue {
|
|||||||
|
|
||||||
public abstract boolean setBlock(final int x, final int y, final int z, final BaseBlock id);
|
public abstract boolean setBlock(final int x, final int y, final int z, final BaseBlock id);
|
||||||
|
|
||||||
|
public boolean setBlock(final int x, final int y, final int z, final Pattern pattern) {
|
||||||
|
return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||||
SchematicHandler.manager.restoreTile(this, tag, x, y, z);
|
SchematicHandler.manager.restoreTile(this, tag, x, y, z);
|
||||||
return true;
|
return true;
|
||||||
@ -64,7 +70,7 @@ public abstract class LocalBlockQueue {
|
|||||||
|
|
||||||
public abstract BlockState getBlock(int x, int y, int z);
|
public abstract BlockState getBlock(int x, int y, int z);
|
||||||
|
|
||||||
public abstract boolean setBiome(int x, int z, String biome);
|
public abstract boolean setBiome(int x, int z, BiomeType biome);
|
||||||
|
|
||||||
public abstract String getWorld();
|
public abstract String getWorld();
|
||||||
|
|
||||||
@ -116,7 +122,7 @@ public abstract class LocalBlockQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCuboid(Location pos1, Location pos2, BlockBucket blocks) {
|
public void setCuboid(Location pos1, Location pos2, Pattern blocks) {
|
||||||
int yMin = Math.min(pos1.getY(), pos2.getY());
|
int yMin = Math.min(pos1.getY(), pos2.getY());
|
||||||
int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY()));
|
int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY()));
|
||||||
int xMin = Math.min(pos1.getX(), pos2.getX());
|
int xMin = Math.min(pos1.getX(), pos2.getX());
|
||||||
@ -126,7 +132,7 @@ public abstract class LocalBlockQueue {
|
|||||||
for (int y = yMin; y <= yMax; y++) {
|
for (int y = yMin; y <= yMax; y++) {
|
||||||
for (int x = xMin; x <= xMax; x++) {
|
for (int x = xMin; x <= xMax; x++) {
|
||||||
for (int z = zMin; z <= zMax; z++) {
|
for (int z = zMin; z <= zMax; z++) {
|
||||||
setBlock(x, y, z, blocks.getBlock());
|
setBlock(x, y, z, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util.block;
|
package com.github.intellectualsites.plotsquared.plot.util.block;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
public class OffsetLocalBlockQueue extends DelegateLocalBlockQueue {
|
public class OffsetLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||||
@ -14,7 +15,7 @@ public class OffsetLocalBlockQueue extends DelegateLocalBlockQueue {
|
|||||||
this.oz = oz;
|
this.oz = oz;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int y, String biome) {
|
@Override public boolean setBiome(int x, int y, BiomeType biome) {
|
||||||
return super.setBiome(ox + x, oy + y, biome);
|
return super.setBiome(ox + x, oy + y, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
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.RunnableVal3;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
@ -38,11 +39,11 @@ public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int z, String biome) {
|
@Override public boolean setBiome(int x, int z, BiomeType biome) {
|
||||||
return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setBiome(x + minX, z + minZ, biome);
|
return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setBiome(x + minX, z + minZ, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillBiome(String biome) {
|
public void fillBiome(BiomeType biome) {
|
||||||
for (int x = 0; x <= dx; x++) {
|
for (int x = 0; x <= dx; x++) {
|
||||||
for (int z = 0; z < dz; z++) {
|
for (int z = 0; z < dz; z++) {
|
||||||
setBiome(x, z, biome);
|
setBiome(x, z, biome);
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util.world;
|
package com.github.intellectualsites.plotsquared.plot.util.world;
|
||||||
|
|
||||||
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.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.util.world;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
|
public class PatternUtil {
|
||||||
|
public static BaseBlock apply(Pattern pattern, int x, int y, int z) {
|
||||||
|
if (pattern instanceof BlockPattern
|
||||||
|
|| pattern instanceof RandomPattern
|
||||||
|
|| pattern instanceof BlockState
|
||||||
|
|| pattern instanceof BlockType
|
||||||
|
|| pattern instanceof BaseBlock) {
|
||||||
|
return pattern.apply(BlockVector3.ZERO);
|
||||||
|
}
|
||||||
|
return pattern.apply(BlockVector3.at(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pattern parse(PlotPlayer plotPlayer, String input) {
|
||||||
|
ParserContext context = new ParserContext();
|
||||||
|
if (plotPlayer != null) {
|
||||||
|
Actor actor = plotPlayer.toActor();
|
||||||
|
context.setActor(actor);
|
||||||
|
if (actor instanceof Player) {
|
||||||
|
context.setWorld(((Player) actor).getWorld());
|
||||||
|
}
|
||||||
|
context.setSession(WorldEdit.getInstance().getSessionManager().get(actor));
|
||||||
|
context.setRestricted(true);
|
||||||
|
} else {
|
||||||
|
context.setRestricted(false);
|
||||||
|
}
|
||||||
|
context.setPreferringWildcard(false);
|
||||||
|
context.setTryLegacy(true);
|
||||||
|
try {
|
||||||
|
Pattern pattern =
|
||||||
|
WorldEdit.getInstance().getPatternFactory().parseFromInput(input, context);
|
||||||
|
return pattern;
|
||||||
|
} catch (InputParseException e) {
|
||||||
|
throw new Command.CommandException(Captions.NOT_VALID_BLOCK, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAir(Pattern pattern) {
|
||||||
|
if (pattern instanceof BlockPattern) {
|
||||||
|
return ((BlockPattern) pattern).getBlock().getBlockType().getMaterial().isAir();
|
||||||
|
}
|
||||||
|
if (pattern instanceof BlockState) {
|
||||||
|
return ((BlockState) pattern).getBlockType().getMaterial().isAir();
|
||||||
|
}
|
||||||
|
if (pattern instanceof BlockType) {
|
||||||
|
return ((BlockType) pattern).getMaterial().isAir();
|
||||||
|
}
|
||||||
|
if (pattern instanceof BaseBlock) {
|
||||||
|
return ((BaseBlock) pattern).getBlockType().getMaterial().isAir();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user