mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2025-08-06 12:33:08 +00:00
Fix multiple schematic issues (which I caused)
This commit is contained in:
parent
c2fff8cbd7
commit
b76899c6e2
9 changed files with 211 additions and 109 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,7 +11,9 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
|
||||
public abstract class ChunkManager {
|
||||
|
||||
|
@ -27,6 +30,72 @@ public abstract class ChunkManager {
|
|||
return new ChunkLoc(x, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* The int[] will be in the form: [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge] and will represent the bottom and top parts of the chunk
|
||||
* @param pos1
|
||||
* @param pos2
|
||||
* @param task
|
||||
* @param whenDone
|
||||
*/
|
||||
public static void chunkTask(Location pos1, Location pos2, final RunnableVal<int[]> task, final Runnable whenDone, final int allocate) {
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
final int p2x = pos2.getX();
|
||||
final int p2z = pos2.getZ();
|
||||
final int bcx = p1x >> 4;
|
||||
final int bcz = p1z >> 4;
|
||||
final int tcx = p2x >> 4;
|
||||
final int tcz = p2z >> 4;
|
||||
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||
|
||||
for (int x = bcx; x <= tcx; x++) {
|
||||
for (int z = bcz; z <= tcz; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long start = System.currentTimeMillis();
|
||||
while (chunks.size() > 0 && System.currentTimeMillis() - start < allocate) {
|
||||
ChunkLoc chunk = chunks.remove(0);
|
||||
task.value = new int[7];
|
||||
task.value[0] = chunk.x;
|
||||
task.value[1] = chunk.z;
|
||||
task.value[2] = task.value[0] << 4;
|
||||
task.value[3] = task.value[1] << 4;
|
||||
task.value[4] = task.value[2] + 15;
|
||||
task.value[5] = task.value[3] + 15;
|
||||
if (task.value[0] == bcx) {
|
||||
task.value[2] = p1x;
|
||||
task.value[6] = 1;
|
||||
}
|
||||
if (task.value[0] == tcx) {
|
||||
task.value[4] = p2x;
|
||||
task.value[6] = 1;
|
||||
}
|
||||
if (task.value[1] == bcz) {
|
||||
task.value[3] = p1z;
|
||||
task.value[6] = 1;
|
||||
}
|
||||
if (task.value[1] == tcz) {
|
||||
task.value[5] = p2z;
|
||||
task.value[6] = 1;
|
||||
}
|
||||
task.run();
|
||||
}
|
||||
if (chunks.size() != 0) {
|
||||
TaskManager.runTaskLater(this, 1);
|
||||
}
|
||||
else {
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract void setChunk(ChunkWrapper loc, PlotBlock[][] result);
|
||||
|
||||
public abstract int[] countEntities(Plot plot);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue