Regenallroads:

- remove the "estimated time" as it's just not remotely correct, nor would it be correct if it were based on actual chunk number
 - fix the air to be pasted above the road when using regenallroads
This commit is contained in:
dordsor21 2019-01-09 16:15:34 +00:00
parent ea01a5171b
commit 727d120e70
2 changed files with 61 additions and 57 deletions

View File

@ -5,15 +5,11 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C; import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotManager; import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotManager;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils; import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
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.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
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 java.util.Set;
@CommandDeclaration(command = "regenallroads", @CommandDeclaration(command = "regenallroads",
description = "Regenerate all roads in the map using the set road schematic", description = "Regenerate all roads in the map using the set road schematic",
aliases = {"rgar"}, usage = "/plot regenallroads <world> [height]", aliases = {"rgar"}, usage = "/plot regenallroads <world> [height]",
@ -46,13 +42,13 @@ import java.util.Set;
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
return false; return false;
} }
Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name); //Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
MainUtil MainUtil
.sendMessage(player, "&cIf no schematic is set, the following will not do anything"); .sendMessage(player, "&cIf no schematic is set, the following will not do anything");
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
MainUtil.sendMessage(player, "&6Potential chunks to update: &7" + (chunks.size() * 1024)); //MainUtil.sendMessage(player, "&6Potential chunks to update: &7" + (chunks.size() * 1024));
MainUtil.sendMessage(player, "&6Estimated time: &7" + chunks.size() + " seconds"); //MainUtil.sendMessage(player, "&6Estimated time: &7" + chunks.size() + " seconds");
boolean result = HybridUtils.manager.scheduleRoadUpdate(area, height); boolean result = HybridUtils.manager.scheduleRoadUpdate(area, height);
if (!result) { if (!result) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,

View File

@ -11,6 +11,7 @@ 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.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
@ -23,6 +24,7 @@ public abstract class HybridUtils {
public static Set<ChunkLoc> chunks = new HashSet<>(); public static Set<ChunkLoc> chunks = new HashSet<>();
public static PlotArea area; public static PlotArea area;
public static boolean UPDATE = false; public static boolean UPDATE = false;
private static BaseBlock air = BlockTypes.AIR.getDefaultState().toBaseBlock();
public abstract void analyzeRegion(String world, RegionWrapper region, public abstract void analyzeRegion(String world, RegionWrapper region,
RunnableVal<PlotAnalysis> whenDone); RunnableVal<PlotAnalysis> whenDone);
@ -161,8 +163,7 @@ public abstract class HybridUtils {
// CANCEL TASK // CANCEL TASK
} else { } else {
final Runnable task = this; final Runnable task = this;
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(() -> {
@Override public void run() {
try { try {
if (chunks.size() < 1024) { if (chunks.size() < 1024) {
if (!regions.isEmpty()) { if (!regions.isEmpty()) {
@ -211,7 +212,6 @@ public abstract class HybridUtils {
PlotSquared.debug("&d - TODO: recommend chunkster if corrupt"); PlotSquared.debug("&d - TODO: recommend chunkster if corrupt");
} }
GlobalBlockQueue.IMP.addTask(() -> TaskManager.runTaskLater(task, 20)); GlobalBlockQueue.IMP.addTask(() -> TaskManager.runTaskLater(task, 20));
}
}); });
} }
} }
@ -283,6 +283,7 @@ public abstract class HybridUtils {
} }
public boolean regenerateRoad(final PlotArea area, final ChunkLoc chunk, int extend) { public boolean regenerateRoad(final PlotArea area, final ChunkLoc chunk, int extend) {
PlotSquared.log(chunk);
int x = chunk.x << 4; int x = chunk.x << 4;
int z = chunk.z << 4; int z = chunk.z << 4;
int ex = x + 15; int ex = x + 15;
@ -353,8 +354,15 @@ public abstract class HybridUtils {
for (int y = 0; y < blocks.length; y++) { for (int y = 0; y < blocks.length; y++) {
if (blocks[y] != null) { if (blocks[y] != null) {
BaseBlock block = blocks[y]; BaseBlock block = blocks[y];
queue.setBlock(x + X + plotWorld.ROAD_OFFSET_X, minY + y, if (block != null) {
queue
.setBlock(x + X + plotWorld.ROAD_OFFSET_X, minY + y,
z + Z + plotWorld.ROAD_OFFSET_Z, block); z + Z + plotWorld.ROAD_OFFSET_Z, block);
} else if (y <= extend) {
queue
.setBlock(x + X + plotWorld.ROAD_OFFSET_X, minY + y,
z + Z + plotWorld.ROAD_OFFSET_Z, air);
}
} }
} }
} }