mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
New experimental async plot clearing
This commit is contained in:
parent
4090cfb306
commit
304decbcef
@ -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");
|
||||
final File sideroad = new File(psRoot + dir + "sideroad.schematic");
|
||||
if (sideroad.exists()) {
|
||||
files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath())));
|
||||
}
|
||||
File intersection = new File(psRoot + dir + "intersection.schematic");
|
||||
final 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");
|
||||
final 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,12 +89,6 @@ 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() {
|
||||
@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;
|
||||
@ -154,28 +141,17 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
setWall(dpw, plot.id, new PlotBlock[] { wall });
|
||||
final Location max = mx;
|
||||
final Location min = mn;
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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);
|
||||
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;
|
||||
} else {
|
||||
}
|
||||
if (min.getX() < plotMinX) {
|
||||
min.setX(plotMinX);
|
||||
}
|
||||
@ -188,204 +164,41 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}, 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);
|
||||
}
|
||||
}, 20);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user