mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-30 00:56:45 +01:00
Optimized fastmode clearing
This commit is contained in:
parent
e8b5edf50b
commit
6c68f88df9
@ -289,64 +289,67 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (chunks.size() == 0) {
|
long start = System.currentTimeMillis();
|
||||||
TaskManager.runTaskLater(whenDone, 1);
|
while (System.currentTimeMillis() - start < 20) {
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
if (chunks.size() == 0) {
|
||||||
TaskManager.tasks.remove(currentIndex);
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
return;
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
}
|
TaskManager.tasks.remove(currentIndex);
|
||||||
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
return;
|
||||||
final Chunk chunk = chunks.get(0);
|
|
||||||
chunks.remove(0);
|
|
||||||
final int x = chunk.getX();
|
|
||||||
final int z = chunk.getZ();
|
|
||||||
boolean loaded = true;
|
|
||||||
if (!chunk.isLoaded()) {
|
|
||||||
final boolean result = chunk.load(false);
|
|
||||||
if (!result) {
|
|
||||||
loaded = false;
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
||||||
|
final Chunk chunk = chunks.get(0);
|
||||||
|
chunks.remove(0);
|
||||||
|
final int x = chunk.getX();
|
||||||
|
final int z = chunk.getZ();
|
||||||
|
boolean loaded = true;
|
||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
loaded = false;
|
final boolean result = chunk.load(false);
|
||||||
}
|
if (!result) {
|
||||||
}
|
loaded = false;
|
||||||
if (loaded) {
|
;
|
||||||
initMaps();
|
|
||||||
final int absX = x << 4;
|
|
||||||
final int absZ = z << 4;
|
|
||||||
boolean save = false;
|
|
||||||
if ((x == c1x) || (z == c1z)) {
|
|
||||||
save = true;
|
|
||||||
for (int X = 0; X < 16; X++) {
|
|
||||||
for (int Z = 0; Z < 16; Z++) {
|
|
||||||
if ((((X + absX) < sx) || ((Z + absZ) < sz)) || (((X + absX) > ex) || ((Z + absZ) > ez))) {
|
|
||||||
saveBlocks(world, maxY, X + absX, Z + absZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if ((x == c2x) || (z == c2z)) {
|
if (!chunk.isLoaded()) {
|
||||||
for (int X = 0; X < 16; X++) {
|
loaded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (loaded) {
|
||||||
|
initMaps();
|
||||||
|
final int absX = x << 4;
|
||||||
|
final int absZ = z << 4;
|
||||||
|
boolean save = false;
|
||||||
|
if ((x == c1x) || (z == c1z)) {
|
||||||
save = true;
|
save = true;
|
||||||
for (int Z = 0; Z < 16; Z++) {
|
for (int X = 0; X < 16; X++) {
|
||||||
if ((((X + absX) > ex) || ((Z + absZ) > ez)) || (((X + absX) < sx) || ((Z + absZ) < sz))) {
|
for (int Z = 0; Z < 16; Z++) {
|
||||||
saveBlocks(world, maxY, X + absX, Z + absZ);
|
if ((((X + absX) < sx) || ((Z + absZ) < sz)) || (((X + absX) > ex) || ((Z + absZ) > ez))) {
|
||||||
|
saveBlocks(world, maxY, X + absX, Z + absZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((x == c2x) || (z == c2z)) {
|
||||||
|
for (int X = 0; X < 16; X++) {
|
||||||
|
save = true;
|
||||||
|
for (int Z = 0; Z < 16; Z++) {
|
||||||
|
if ((((X + absX) > ex) || ((Z + absZ) > ez)) || (((X + absX) < sx) || ((Z + absZ) < sz))) {
|
||||||
|
saveBlocks(world, maxY, X + absX, Z + absZ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (save) {
|
||||||
|
saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR);
|
||||||
|
}
|
||||||
|
world.regenerateChunk(x, z);
|
||||||
|
if (save) {
|
||||||
|
restoreBlocks(world, 0, 0);
|
||||||
|
restoreEntities(world, 0, 0);
|
||||||
|
}
|
||||||
|
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
||||||
|
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
||||||
}
|
}
|
||||||
if (save) {
|
CURRENT_PLOT_CLEAR = null;
|
||||||
saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR);
|
|
||||||
}
|
|
||||||
world.regenerateChunk(x, z);
|
|
||||||
if (save) {
|
|
||||||
restoreBlocks(world, 0, 0);
|
|
||||||
restoreEntities(world, 0, 0);
|
|
||||||
}
|
|
||||||
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
|
||||||
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
|
||||||
}
|
}
|
||||||
CURRENT_PLOT_CLEAR = null;
|
|
||||||
}
|
}
|
||||||
}, 1, 1);
|
}, 1, 1);
|
||||||
TaskManager.tasks.put(currentIndex, task);
|
TaskManager.tasks.put(currentIndex, task);
|
||||||
|
@ -151,7 +151,11 @@ public class BukkitUtil extends BlockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void regenerateChunk(final String world, final int x, final int z) {
|
public static void regenerateChunk(final String world, final int x, final int z) {
|
||||||
getWorld(world).regenerateChunk(x, z);
|
World worldObj = getWorld(world);
|
||||||
|
Chunk chunk = worldObj.getChunkAt(x, z);
|
||||||
|
if (chunk.isLoaded() || chunk.load(false)) {
|
||||||
|
worldObj.regenerateChunk(x, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlotBlock getBlock(final Location loc) {
|
public static PlotBlock getBlock(final Location loc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user