mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Use worldedit to regenerate chunks. (#2708)
* Use worldedit to regeneration chunks. It's very slow, but it works. * Use the AutoClose-ness of EditSession
This commit is contained in:
parent
d9f9d7dc34
commit
3d47d7e73f
3 changed files with 22 additions and 6 deletions
|
@ -290,10 +290,9 @@ public class BukkitChunkManager extends ChunkManager {
|
|||
continue;
|
||||
}
|
||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z
|
||||
&& PlotSquared.imp().getServerVersion()[1] == 13) {
|
||||
AugmentedUtils
|
||||
.bypass(ignoreAugment, () -> queue.regenChunkSafe(chunk.getX(), chunk.getZ()));
|
||||
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
||||
AugmentedUtils.bypass(ignoreAugment,
|
||||
() -> queue.regenChunkSafe(chunk.getX(), chunk.getZ()));
|
||||
continue;
|
||||
}
|
||||
boolean checkX1 = false;
|
||||
|
|
|
@ -7,7 +7,13 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|||
import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
@ -64,7 +70,18 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
|
|||
@Override public final void regenChunk(int x, int z) {
|
||||
World worldObj = Bukkit.getWorld(getWorld());
|
||||
if (worldObj != null) {
|
||||
worldObj.regenerateChunk(x, z);
|
||||
try {
|
||||
worldObj.regenerateChunk(x, z);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(worldObj);
|
||||
try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||
.getEditSession(world, -1);) {
|
||||
CuboidRegion region =
|
||||
new CuboidRegion(world, BlockVector3.at((x << 4), 0, (z << 4)),
|
||||
BlockVector3.at((x << 4) + 15, 255, (z << 4) + 15));
|
||||
world.regenerate(region, editSession);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PlotSquared.debug("Error Regenerating Chunk");
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override public void run(int[] value) {
|
||||
// If the chunk isn't near the edge and it isn't an augmented world we can just regen the whole chunk
|
||||
if (canRegen && (value[6] == 0) && PlotSquared.imp().getServerVersion()[1] == 13) {
|
||||
if (canRegen && (value[6] == 0)) {
|
||||
queue.regenChunk(value[0], value[1]);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue