Fix plot walls after running regenallroads

Also clears whatever was above the plot wall, such as pieces of the road.
This commit is contained in:
Alexander Krivács Schrøder 2019-06-01 14:43:29 +02:00 committed by Matt
parent a94c588a17
commit 7f404e1cf5
5 changed files with 62 additions and 6 deletions

View file

@ -250,17 +250,28 @@ public class ClassicPlotManager extends SquarePlotManager {
Location top = plot.getExtendedTopAbs().add(1, 0, 1); Location top = plot.getExtendedTopAbs().add(1, 0, 1);
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
int y = classicPlotWorld.WALL_HEIGHT + 1; int y = classicPlotWorld.WALL_HEIGHT + 1;
StringPlotBlock air = PlotBlock.get("air");
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.getBlock());
} }
// Replace all blocks above the wall with air
queue.setCuboid(
new Location(top.getWorld(), top.getX(), y + 1, bot.getZ()),
new Location(bot.getWorld(), bot.getX(), 255, bot.getZ()),
air);
} }
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.getBlock());
} }
// Replace all blocks above the wall with air
queue.setCuboid(
new Location(top.getWorld(), bot.getX(), y + 1, top.getZ()),
new Location(bot.getWorld(), bot.getX(), 255, bot.getZ()),
air);
} }
if (!plot.getMerged(Direction.SOUTH)) { if (!plot.getMerged(Direction.SOUTH)) {
int z = top.getZ(); int z = top.getZ();
@ -268,6 +279,11 @@ public class ClassicPlotManager extends SquarePlotManager {
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.getBlock());
} }
// Replace all blocks above the wall with air
queue.setCuboid(
new Location(top.getWorld(), top.getX(), y + 1, top.getZ()),
new Location(bot.getWorld(), bot.getX(), 255, top.getZ()),
air);
} }
if (!plot.getMerged(Direction.EAST)) { if (!plot.getMerged(Direction.EAST)) {
int x = top.getX(); int x = top.getX();
@ -275,6 +291,11 @@ public class ClassicPlotManager extends SquarePlotManager {
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.getBlock());
} }
// Replace all blocks above the wall with air
queue.setCuboid(
new Location(top.getWorld(), top.getX(), y + 1, top.getZ()),
new Location(bot.getWorld(), top.getX(), 255, bot.getZ()),
air);
} }
queue.enqueue(); queue.enqueue();
return true; return true;
@ -439,6 +460,17 @@ public class ClassicPlotManager extends SquarePlotManager {
return true; return true;
} }
@Override public boolean regenerateAllPlotWalls() {
for (Plot plot : classicPlotWorld.getPlots()) {
if (plot.hasOwner()) {
setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK);
} else {
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
}
}
return true;
}
@Override public boolean startPlotMerge(List<PlotId> plotIds) { @Override public boolean startPlotMerge(List<PlotId> plotIds) {
return true; return true;
} }

View file

@ -153,6 +153,9 @@ public abstract class HybridUtils {
PlotSquared.debug("PROGRESS: " + 100 * (2048 - chunks.size()) / 2048 + "%"); PlotSquared.debug("PROGRESS: " + 100 * (2048 - chunks.size()) / 2048 + "%");
} }
if (regions.isEmpty() && chunks.isEmpty()) { if (regions.isEmpty() && chunks.isEmpty()) {
PlotSquared.debug("&3Regenerating plot walls");
regeneratePlotWalls(area);
HybridUtils.UPDATE = false; HybridUtils.UPDATE = false;
PlotSquared.debug(Captions.PREFIX.s() + "Finished road conversion"); PlotSquared.debug(Captions.PREFIX.s() + "Finished road conversion");
// CANCEL TASK // CANCEL TASK
@ -377,4 +380,9 @@ public abstract class HybridUtils {
} }
return false; return false;
} }
public boolean regeneratePlotWalls(final PlotArea area) {
PlotManager plotManager = area.getPlotManager();
return plotManager.regenerateAllPlotWalls();
}
} }

View file

@ -85,4 +85,6 @@ public abstract class PlotManager {
return 255; return 255;
} }
public abstract boolean regenerateAllPlotWalls();
} }

View file

@ -107,4 +107,6 @@ public class SinglePlotManager extends PlotManager {
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) { @Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
return false; return false;
} }
@Override public boolean regenerateAllPlotWalls() { return false; }
} }

View file

@ -97,9 +97,15 @@ public abstract class LocalBlockQueue {
} }
public void setCuboid(Location pos1, Location pos2, PlotBlock block) { public void setCuboid(Location pos1, Location pos2, PlotBlock block) {
for (int y = pos1.getY(); y <= Math.min(255, pos2.getY()); y++) { int yMin = Math.min(pos1.getY(), pos2.getY());
for (int x = pos1.getX(); x <= pos2.getX(); x++) { int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY()));
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) { int xMin = Math.min(pos1.getX(), pos2.getX());
int xMax = Math.max(pos1.getX(), pos2.getX());
int zMin = Math.min(pos1.getZ(), pos2.getZ());
int zMax = Math.max(pos1.getZ(), pos2.getZ());
for (int y = yMin; y <= yMax; y++) {
for (int x = xMin; x <= xMax; x++) {
for (int z = zMin; z <= zMax; z++) {
setBlock(x, y, z, block); setBlock(x, y, z, block);
} }
} }
@ -107,9 +113,15 @@ public abstract class LocalBlockQueue {
} }
public void setCuboid(Location pos1, Location pos2, BlockBucket blocks) { public void setCuboid(Location pos1, Location pos2, BlockBucket blocks) {
for (int y = pos1.getY(); y <= Math.min(255, pos2.getY()); y++) { int yMin = Math.min(pos1.getY(), pos2.getY());
for (int x = pos1.getX(); x <= pos2.getX(); x++) { int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY()));
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) { int xMin = Math.min(pos1.getX(), pos2.getX());
int xMax = Math.max(pos1.getX(), pos2.getX());
int zMin = Math.min(pos1.getZ(), pos2.getZ());
int zMax = Math.max(pos1.getZ(), pos2.getZ());
for (int y = yMin; y <= yMax; y++) {
for (int x = xMin; x <= xMax; x++) {
for (int z = zMin; z <= zMax; z++) {
setBlock(x, y, z, blocks.getBlock()); setBlock(x, y, z, blocks.getBlock());
} }
} }