mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Regenallroads can now remove existing road schematic + fixed sch save from console
This commit is contained in:
parent
7d9963d386
commit
f380e49d15
@ -8,6 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
|
<version>2.11.20</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -34,6 +34,7 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
@ -72,11 +73,15 @@ public class DebugExec extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean result;
|
boolean result;
|
||||||
|
if (!PlotSquared.isPlotWorld(args[1])) {
|
||||||
|
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (BukkitHybridUtils.regions != null) {
|
if (BukkitHybridUtils.regions != null) {
|
||||||
result = ((BukkitHybridUtils)(HybridUtils.manager)).scheduleRoadUpdate(args[1], BukkitHybridUtils.regions);
|
result = ((BukkitHybridUtils)(HybridUtils.manager)).scheduleRoadUpdate(args[1], BukkitHybridUtils.regions, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = HybridUtils.manager.scheduleRoadUpdate(args[1]);
|
result = HybridUtils.manager.scheduleRoadUpdate(args[1], 0);
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
|
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) {
|
while (BukkitHybridUtils.chunks.size() > 0) {
|
||||||
ChunkLoc chunk = BukkitHybridUtils.chunks.get(0);
|
ChunkLoc chunk = BukkitHybridUtils.chunks.get(0);
|
||||||
BukkitHybridUtils.chunks.remove(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);
|
ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk);
|
||||||
}
|
}
|
||||||
PlotSquared.log("&cCancelled!");
|
PlotSquared.log("&cCancelled!");
|
||||||
|
@ -42,7 +42,7 @@ public class DebugRoadRegen extends SubCommand {
|
|||||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||||
}
|
}
|
||||||
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
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"));
|
MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,21 @@ public class RegenAllRoads extends SubCommand {
|
|||||||
sendMessage(player, C.NOT_CONSOLE);
|
sendMessage(player, C.NOT_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 1) {
|
if (args.length < 1) {
|
||||||
sendMessage(player, C.NEED_PLOT_WORLD);
|
sendMessage(player, C.NEED_PLOT_WORLD);
|
||||||
return false;
|
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 String name = args[0];
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(name);
|
final PlotManager manager = PlotSquared.getPlotManager(name);
|
||||||
if ((manager == null) || !(manager instanceof HybridPlotManager)) {
|
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("&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("&6Potential chunks to update: &7" + (chunks.size() * 1024));
|
||||||
PlotSquared.log("&6Estimated time: &7" + (chunks.size()) + " seconds");
|
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) {
|
if (!result) {
|
||||||
PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
|
PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
|
||||||
return false;
|
return false;
|
||||||
|
@ -240,7 +240,7 @@ public class SchematicCmd extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
try {
|
try {
|
||||||
world = args[0];
|
world = args[1];
|
||||||
final String[] split = args[2].split(";");
|
final String[] split = args[2].split(";");
|
||||||
final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||||
if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) {
|
if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) {
|
||||||
|
@ -148,7 +148,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
for (int z = sz; z < (sz + 32); z++) {
|
for (int z = sz; z < (sz + 32); z++) {
|
||||||
final Chunk chunk = world.getChunkAt(x, z);
|
final Chunk chunk = world.getChunkAt(x, z);
|
||||||
chunks2.add(chunk);
|
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()));
|
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,20 +171,20 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
private long last;
|
private long last;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean scheduleRoadUpdate(final String world) {
|
public boolean scheduleRoadUpdate(final String world, int extend) {
|
||||||
if (BukkitHybridUtils.UPDATE) {
|
if (BukkitHybridUtils.UPDATE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BukkitHybridUtils.UPDATE = true;
|
BukkitHybridUtils.UPDATE = true;
|
||||||
final List<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(world);
|
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> regions;
|
||||||
public static List<ChunkLoc> chunks = new ArrayList<>();
|
public static List<ChunkLoc> chunks = new ArrayList<>();
|
||||||
public static String world;
|
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.regions = rgs;
|
||||||
BukkitHybridUtils.world = world;
|
BukkitHybridUtils.world = world;
|
||||||
chunks = new ArrayList<ChunkLoc>();
|
chunks = new ArrayList<ChunkLoc>();
|
||||||
@ -195,7 +195,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
public void run() {
|
public void run() {
|
||||||
count.increment();
|
count.increment();
|
||||||
if (count.intValue() % 20 == 0) {
|
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) {
|
if (regions.size() == 0 && chunks.size() == 0) {
|
||||||
BukkitHybridUtils.UPDATE = false;
|
BukkitHybridUtils.UPDATE = false;
|
||||||
@ -222,14 +222,14 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
while (chunks.size() > 0) {
|
while (chunks.size() > 0) {
|
||||||
ChunkLoc chunk = chunks.get(0);
|
ChunkLoc chunk = chunks.get(0);
|
||||||
chunks.remove(0);
|
chunks.remove(0);
|
||||||
regenerateRoad(world, chunk);
|
regenerateRoad(world, chunk, extend);
|
||||||
ChunkManager.manager.unloadChunk(world, chunk);
|
ChunkManager.manager.unloadChunk(world, chunk);
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
|
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
scheduleRoadUpdate(world, regions);
|
scheduleRoadUpdate(world, regions, extend);
|
||||||
}
|
}
|
||||||
}, 2400);
|
}, 2400);
|
||||||
return;
|
return;
|
||||||
@ -238,7 +238,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
while (System.currentTimeMillis() < diff && chunks.size() > 0) {
|
while (System.currentTimeMillis() < diff && chunks.size() > 0) {
|
||||||
ChunkLoc chunk = chunks.get(0);
|
ChunkLoc chunk = chunks.get(0);
|
||||||
chunks.remove(0);
|
chunks.remove(0);
|
||||||
regenerateRoad(world, chunk);
|
regenerateRoad(world, chunk, extend);
|
||||||
ChunkManager.manager.unloadChunk(world, chunk);
|
ChunkManager.manager.unloadChunk(world, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 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 x = chunk.x << 4;
|
||||||
final int z = chunk.z << 4;
|
final int z = chunk.z << 4;
|
||||||
final int ex = x + 15;
|
final int ex = x + 15;
|
||||||
final int ez = z + 15;
|
final int ez = z + 15;
|
||||||
final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world);
|
final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world);
|
||||||
|
extend = Math.min(extend, 255 - plotworld.ROAD_HEIGHT - plotworld.SCHEMATIC_HEIGHT);
|
||||||
if (!plotworld.ROAD_SCHEMATIC_ENABLED) {
|
if (!plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -125,7 +126,7 @@ public abstract class HybridUtils {
|
|||||||
final int sy = plotworld.ROAD_HEIGHT;
|
final int sy = plotworld.ROAD_HEIGHT;
|
||||||
final PlotLoc loc = new PlotLoc(absX, absZ);
|
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||||
final HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
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);
|
BlockManager.manager.functionSetBlock(world, x + X, y, z + Z, 0, (byte) 0);
|
||||||
}
|
}
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user