New experimental async plot clearing

This commit is contained in:
boy0001 2015-04-30 14:33:57 +10:00
parent 4090cfb306
commit 304decbcef
3 changed files with 165 additions and 316 deletions

View File

@ -34,39 +34,40 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SetBlockQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
public class HybridPlotManager extends ClassicPlotManager {
@Override
public void exportTemplate(PlotWorld plotworld) throws IOException {
HashSet<FileBytes> files = new HashSet<>(Arrays.asList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
String psRoot = PlotSquared.IMP.getDirectory() + File.separator;
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
public void exportTemplate(final PlotWorld plotworld) throws IOException {
final HashSet<FileBytes> files = new HashSet<>(Arrays.asList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
final String psRoot = PlotSquared.IMP.getDirectory() + File.separator;
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
final String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
try {
File sideroad = new File(psRoot + dir + "sideroad.schematic");
if (sideroad.exists()) {
files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath())));
final File sideroad = new File(psRoot + dir + "sideroad.schematic");
if (sideroad.exists()) {
files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath())));
}
final File intersection = new File(psRoot + dir + "intersection.schematic");
if (intersection.exists()) {
files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath())));
}
final File plot = new File(psRoot + dir + "plot.schematic");
if (plot.exists()) {
files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath())));
}
}
File intersection = new File(psRoot + dir + "intersection.schematic");
if (intersection.exists()) {
files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath())));
}
File plot = new File(psRoot + dir + "plot.schematic");
if (plot.exists()) {
files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath())));
}
}
catch (Exception e) {
catch (final Exception e) {
e.printStackTrace();
}
Template.zipAll(plotworld.worldname, files);
}
/**
* Clearing the plot needs to only consider removing the blocks - This implementation has used the SetCuboid
* Clearing the plot needs to only consider removing the blocks - This implementation has used the setCuboidAsync
* function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster
* than block updates This code is very messy, but you don't need to do something quite as complex unless you happen
* to have 512x512 sized plots
@ -74,19 +75,11 @@ public class HybridPlotManager extends ClassicPlotManager {
@Override
public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) {
final String world = plotworld.worldname;
MainUtil.runners.put(plot, 1);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.runners.remove(plot);
}
}, 90);
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1);
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id);
final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
final PlotBlock[] filling = dpw.MAIN_BLOCK;
// PlotBlock wall = dpw.WALL_BLOCK;
final PlotBlock wall;
if (isDelete) {
wall = dpw.WALL_BLOCK;
@ -96,296 +89,116 @@ public class HybridPlotManager extends ClassicPlotManager {
final PlotBlock wall_filling = dpw.WALL_FILLING;
setWallFilling(dpw, plot.id, new PlotBlock[] { wall_filling });
final int maxy = BukkitUtil.getMaxHeight(world);
TaskManager.runTaskLater(new Runnable() {
final short bedrock = (short) (dpw.PLOT_BEDROCK ? 7 : 0);
final int startX = (pos1.getX() / 16) * 16;
final int startZ = (pos1.getZ() / 16) * 16;
final int chunkX = 16 + pos2.getX();
final int chunkZ = 16 + pos2.getZ();
final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id);
final Location l2 = MainUtil.getPlotTopLoc(world, plot.id);
final int plotMinX = l1.getX() + 1;
final int plotMinZ = l1.getZ() + 1;
final int plotMaxX = l2.getX();
final int plotMaxZ = l2.getZ();
Location mn = null;
Location mx = null;
for (int i = startX; i < chunkX; i += 16) {
for (int j = startZ; j < chunkZ; j += 16) {
final Plot plot1 = MainUtil.getPlot(new Location(world, i, 0, j));
if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) {
break;
}
final Plot plot2 = MainUtil.getPlot(new Location(world, i + 15, 0, j));
if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) {
break;
}
final Plot plot3 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15));
if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) {
break;
}
final Plot plot4 = MainUtil.getPlot(new Location(world, i, 0, j + 15));
if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) {
break;
}
final Plot plot5 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15));
if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) {
break;
}
if (mn == null) {
mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ));
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
} else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) {
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
}
final int I = i;
final int J = j;
BukkitUtil.regenerateChunk(world, I / 16, J / 16);
if (!MainUtil.canSendChunk) {
BukkitUtil.refreshChunk(world, I / 16, J / 16);
}
}
}
setWall(dpw, plot.id, new PlotBlock[] { wall });
final Location max = mx;
final Location min = mn;
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
final short bedrock = (short) (dpw.PLOT_BEDROCK ? 7 : 0);
final int startX = (pos1.getX() / 16) * 16;
final int startZ = (pos1.getZ() / 16) * 16;
final int chunkX = 16 + pos2.getX();
final int chunkZ = 16 + pos2.getZ();
final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id);
final Location l2 = MainUtil.getPlotTopLoc(world, plot.id);
final int plotMinX = l1.getX() + 1;
final int plotMinZ = l1.getZ() + 1;
final int plotMaxX = l2.getX();
final int plotMaxZ = l2.getZ();
Location mn = null;
Location mx = null;
for (int i = startX; i < chunkX; i += 16) {
for (int j = startZ; j < chunkZ; j += 16) {
final Plot plot1 = MainUtil.getPlot(new Location(world, i, 0, j));
if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) {
break;
}
final Plot plot2 = MainUtil.getPlot(new Location(world, i + 15, 0, j));
if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) {
break;
}
final Plot plot3 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15));
if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) {
break;
}
final Plot plot4 = MainUtil.getPlot(new Location(world, i, 0, j + 15));
if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) {
break;
}
final Plot plot5 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15));
if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) {
break;
}
if (mn == null) {
mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ));
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
} else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) {
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
}
final int I = i;
final int J = j;
BukkitUtil.regenerateChunk(world, I / 16, J / 16);
if (!MainUtil.canSendChunk) {
BukkitUtil.refreshChunk(world, I / 16, J / 16);
}
}
}
setWall(dpw, plot.id, new PlotBlock[] { wall });
final Location max = mx;
final Location min = mn;
if (min == null) {
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor);
}
}, 5);
}
}, 5);
}
}, 5);
return;
} else {
if (min.getX() < plotMinX) {
min.setX(plotMinX);
}
if (min.getZ() < plotMinZ) {
min.setZ(plotMinZ);
}
if (max.getX() > plotMaxX) {
max.setX(plotMaxX);
}
if (max.getZ() > plotMaxZ) {
max.setZ(plotMaxZ);
}
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
}
}, 1);
}
}, 1);
}
}, 1);
}
}, 21);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, plotMinZ), new Location(world, max.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, min.getX(), 1, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
}
}, 1);
}
}, 1);
}
}, 1);
}
}, 25);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, max.getX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
}
}, 1);
}
}, 1);
}
}, 1);
}
}, 29);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getZ()), new Location(world, min.getX() + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor);
}
}, 1);
}
}, 1);
}
}, 1);
}
}, 33);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getZ()), new Location(world, min.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
}
}, 1);
}
}, 1);
}
}, 1);
}
}, 37);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, max.getZ()), new Location(world, max.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, min.getX(), 1, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
}
}, 1);
}
}, 1);
}
}, 1);
}
}, 41);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, min.getZ()), new Location(world, plotMaxX + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, max.getX(), 1, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor);
}
}, 1);
}
}, 1);
}
}, 1);
}
}, 45);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, max.getZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, max.getX(), 1, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
TaskManager.runTask(whenDone);
}
}, 1);
}
}, 1);
}
}, 1);
}
}, 49);
}
}
}, 20);
if (min == null) {
MainUtil.setSimpleCuboidAsync(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor);
SetBlockQueue.addNotify(whenDone);
return;
}
if (min.getX() < plotMinX) {
min.setX(plotMinX);
}
if (min.getZ() < plotMinZ) {
min.setZ(plotMinZ);
}
if (max.getX() > plotMaxX) {
max.setX(plotMaxX);
}
if (max.getZ() > plotMaxZ) {
max.setZ(plotMaxZ);
}
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), 0, plotMinZ), new Location(world, max.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, min.getX(), 1, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, min.getZ()), new Location(world, min.getX() + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor);
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, max.getZ()), new Location(world, min.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), 0, max.getZ()), new Location(world, max.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, min.getX(), 1, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, min.getZ()), new Location(world, plotMaxX + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor);
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, max.getZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
SetBlockQueue.addNotify(whenDone);
}
}, 20);
});
return true;
}
}

View File

@ -601,6 +601,7 @@ public class MainUtil {
*/
public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) {
if (runners.containsKey(plot)) {
System.out.print("RUNNABLE ALREADY");
return false;
}
ChunkManager.manager.clearAllEntities(plot);
@ -610,6 +611,7 @@ public class MainUtil {
}
public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) {
System.out.print(1);
final PlotManager manager = PlotSquared.getPlotManager(world);
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final int prime = 31;
@ -620,20 +622,24 @@ public class MainUtil {
System.currentTimeMillis();
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
runners.put(plot, 1);
System.out.print(2);
if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) {
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
@Override
public void run() {
System.out.print(3);
runners.remove(plot);
TaskManager.runTask(whenDone);
}
});
return;
}
System.out.print(2.1);
final Runnable run = new Runnable() {
@Override
public void run() {
System.out.print(3.1);
MainUtil.setBiome(world, plot, "FOREST");
runners.remove(plot);
TaskManager.runTask(whenDone);
@ -671,6 +677,22 @@ public class MainUtil {
BlockManager.setBlocks(world, xl, yl, zl, ids, data);
}
public static void setCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
if (blocks.length == 1) {
setSimpleCuboidAsync(world, pos1, pos2, blocks[0]);
return;
}
for (int y = pos1.getY(); y < pos2.getY(); y++) {
for (int x = pos1.getX(); x < pos2.getX(); x++) {
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
final int i = random.random(blocks.length);
final PlotBlock block = blocks[i];
SetBlockQueue.setBlock(world, x, y, z, block);
}
}
}
}
public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ());
final int[] xl = new int[length];
@ -694,6 +716,16 @@ public class MainUtil {
BlockManager.setBlocks(world, xl, yl, zl, ids, data);
}
public static void setSimpleCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
for (int y = pos1.getY(); y < pos2.getY(); y++) {
for (int x = pos1.getX(); x < pos2.getX(); x++) {
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
SetBlockQueue.setBlock(world, x, y, z, newblock);
}
}
}
}
public static void setBiome(final String world, final Plot plot, final String biome) {
final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1;
final int topX = getPlotTopLoc(world, plot.id).getX();

View File

@ -279,6 +279,8 @@ public class BukkitChunkManager extends ChunkManager {
final int c2x = c2.getX();
final int c2z = c2.getZ();
System.out.print(4);
final ArrayList<Chunk> chunks = new ArrayList<Chunk>();
for (int x = c1x; x <= c2x; x++) {
for (int z = c1z; z <= c2z; z++) {
@ -295,11 +297,13 @@ public class BukkitChunkManager extends ChunkManager {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < 20) {
if (chunks.size() == 0) {
System.out.print(5);
TaskManager.runTaskLater(whenDone, 1);
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
return;
}
System.out.print(6);
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
final Chunk chunk = chunks.get(0);
chunks.remove(0);