Regenallroads can now remove existing road schematic + fixed sch save from console

This commit is contained in:
boy0001 2015-06-11 10:56:53 +10:00
parent 7d9963d386
commit f380e49d15
7 changed files with 36 additions and 18 deletions

View File

@ -8,6 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<artifactId>PlotSquared</artifactId>
<version>2.11.20</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

@ -34,6 +34,7 @@ import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.ChunkLoc;
@ -72,11 +73,15 @@ public class DebugExec extends SubCommand {
return false;
}
boolean result;
if (!PlotSquared.isPlotWorld(args[1])) {
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]);
return false;
}
if (BukkitHybridUtils.regions != null) {
result = ((BukkitHybridUtils)(HybridUtils.manager)).scheduleRoadUpdate(args[1], BukkitHybridUtils.regions);
result = ((BukkitHybridUtils)(HybridUtils.manager)).scheduleRoadUpdate(args[1], BukkitHybridUtils.regions, 0);
}
else {
result = HybridUtils.manager.scheduleRoadUpdate(args[1]);
result = HybridUtils.manager.scheduleRoadUpdate(args[1], 0);
}
if (!result) {
PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
@ -94,7 +99,7 @@ public class DebugExec extends SubCommand {
while (BukkitHybridUtils.chunks.size() > 0) {
ChunkLoc chunk = BukkitHybridUtils.chunks.get(0);
BukkitHybridUtils.chunks.remove(0);
((BukkitHybridUtils)(HybridUtils.manager)).regenerateRoad(BukkitHybridUtils.world, chunk);
((BukkitHybridUtils)(HybridUtils.manager)).regenerateRoad(BukkitHybridUtils.world, chunk, 0);
ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk);
}
PlotSquared.log("&cCancelled!");

View File

@ -42,7 +42,7 @@ public class DebugRoadRegen extends SubCommand {
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
}
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
final boolean result = HybridUtils.manager.regenerateRoad(world, chunk);
final boolean result = HybridUtils.manager.regenerateRoad(world, chunk, 0);
MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
return true;
}

View File

@ -42,10 +42,21 @@ public class RegenAllRoads extends SubCommand {
sendMessage(player, C.NOT_CONSOLE);
return false;
}
if (args.length != 1) {
if (args.length < 1) {
sendMessage(player, C.NEED_PLOT_WORLD);
return false;
}
int height = 0;
if (args.length == 2) {
try {
height = Integer.parseInt(args[1]);
}
catch (NumberFormatException e) {
sendMessage(player, C.NOT_VALID_NUMBER);
sendMessage(player, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
return false;
}
}
final String name = args[0];
final PlotManager manager = PlotSquared.getPlotManager(name);
if ((manager == null) || !(manager instanceof HybridPlotManager)) {
@ -57,7 +68,7 @@ public class RegenAllRoads extends SubCommand {
PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
PlotSquared.log("&6Potential chunks to update: &7" + (chunks.size() * 1024));
PlotSquared.log("&6Estimated time: &7" + (chunks.size()) + " seconds");
final boolean result = HybridUtils.manager.scheduleRoadUpdate(name);
final boolean result = HybridUtils.manager.scheduleRoadUpdate(name, height);
if (!result) {
PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
return false;

View File

@ -240,7 +240,7 @@ public class SchematicCmd extends SubCommand {
} else {
if (args.length == 3) {
try {
world = args[0];
world = args[1];
final String[] split = args[2].split(";");
final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) {

View File

@ -148,7 +148,7 @@ public class BukkitHybridUtils extends HybridUtils {
for (int z = sz; z < (sz + 32); z++) {
final Chunk chunk = world.getChunkAt(x, z);
chunks2.add(chunk);
regenerateRoad(worldname, new ChunkLoc(x, z));
regenerateRoad(worldname, new ChunkLoc(x, z), 0);
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
}
}
@ -171,20 +171,20 @@ public class BukkitHybridUtils extends HybridUtils {
private long last;
@Override
public boolean scheduleRoadUpdate(final String world) {
public boolean scheduleRoadUpdate(final String world, int extend) {
if (BukkitHybridUtils.UPDATE) {
return false;
}
BukkitHybridUtils.UPDATE = true;
final List<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(world);
return scheduleRoadUpdate(world, regions);
return scheduleRoadUpdate(world, regions, extend);
}
public static List<ChunkLoc> regions;
public static List<ChunkLoc> chunks = new ArrayList<>();
public static String world;
public boolean scheduleRoadUpdate(final String world, final List<ChunkLoc> rgs) {
public boolean scheduleRoadUpdate(final String world, final List<ChunkLoc> rgs, final int extend) {
BukkitHybridUtils.regions = rgs;
BukkitHybridUtils.world = world;
chunks = new ArrayList<ChunkLoc>();
@ -195,7 +195,7 @@ public class BukkitHybridUtils extends HybridUtils {
public void run() {
count.increment();
if (count.intValue() % 20 == 0) {
PlotSquared.log("PROGRESS: " + ((100 * (2048 - chunks.size())) / 1024) + "%");
PlotSquared.log("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%");
}
if (regions.size() == 0 && chunks.size() == 0) {
BukkitHybridUtils.UPDATE = false;
@ -222,14 +222,14 @@ public class BukkitHybridUtils extends HybridUtils {
while (chunks.size() > 0) {
ChunkLoc chunk = chunks.get(0);
chunks.remove(0);
regenerateRoad(world, chunk);
regenerateRoad(world, chunk, extend);
ChunkManager.manager.unloadChunk(world, chunk);
}
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
scheduleRoadUpdate(world, regions);
scheduleRoadUpdate(world, regions, extend);
}
}, 2400);
return;
@ -238,7 +238,7 @@ public class BukkitHybridUtils extends HybridUtils {
while (System.currentTimeMillis() < diff && chunks.size() > 0) {
ChunkLoc chunk = chunks.get(0);
chunks.remove(0);
regenerateRoad(world, chunk);
regenerateRoad(world, chunk, extend);
ChunkManager.manager.unloadChunk(world, chunk);
}
}

View File

@ -59,14 +59,15 @@ public abstract class HybridUtils {
public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy);
public abstract boolean scheduleRoadUpdate(final String world);
public abstract boolean scheduleRoadUpdate(final String world, int extend);
public boolean regenerateRoad(final String world, final ChunkLoc chunk) {
public boolean regenerateRoad(final String world, final ChunkLoc chunk, int extend) {
final int x = chunk.x << 4;
final int z = chunk.z << 4;
final int ex = x + 15;
final int ez = z + 15;
final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world);
extend = Math.min(extend, 255 - plotworld.ROAD_HEIGHT - plotworld.SCHEMATIC_HEIGHT);
if (!plotworld.ROAD_SCHEMATIC_ENABLED) {
return false;
}
@ -125,7 +126,7 @@ public abstract class HybridUtils {
final int sy = plotworld.ROAD_HEIGHT;
final PlotLoc loc = new PlotLoc(absX, absZ);
final HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
for (short y = (short) (plotworld.ROAD_HEIGHT); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT); y++) {
for (short y = (short) (plotworld.ROAD_HEIGHT); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend); y++) {
BlockManager.manager.functionSetBlock(world, x + X, y, z + Z, 0, (byte) 0);
}
if (blocks != null) {