mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-27 09:56:41 +00:00
Added /listchunks and /delchunks.
This commit is contained in:
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.data;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import org.jnbt.*;
|
||||
|
||||
/**
|
||||
@ -32,6 +32,37 @@ import org.jnbt.*;
|
||||
* @author sk89q
|
||||
*/
|
||||
public abstract class NestedFileChunkStore extends ChunkStore {
|
||||
/**
|
||||
* Get the filename of a chunk.
|
||||
*
|
||||
* @param pos
|
||||
* @param separator
|
||||
* @return
|
||||
*/
|
||||
public static String getFilename(Vector2D pos, String separator) {
|
||||
int x = pos.getBlockX();
|
||||
int z = pos.getBlockZ();
|
||||
|
||||
String folder1 = Integer.toString(divisorMod(x, 64), 36);
|
||||
String folder2 = Integer.toString(divisorMod(z, 64), 36);
|
||||
String filename = "c." + Integer.toString(x, 36)
|
||||
+ "." + Integer.toString(z, 36) + ".dat";
|
||||
|
||||
return folder1 + separator + folder2 + separator + filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename of a chunk, using the system's default path
|
||||
* separator.
|
||||
*
|
||||
* @param pos
|
||||
* @param separator
|
||||
* @return
|
||||
*/
|
||||
public static String getFilename(Vector2D pos) {
|
||||
return getFilename(pos, File.separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag for a chunk.
|
||||
*
|
||||
|
@ -20,7 +20,11 @@
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.data.ChunkStore;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -261,6 +265,29 @@ public class CuboidRegion implements Region {
|
||||
this.pos2 = pos2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of chunks that this region is within.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Vector2D> getChunks() {
|
||||
Set<Vector2D> chunks = new HashSet<Vector2D>();
|
||||
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
|
||||
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
|
||||
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
chunks.add(ChunkStore.toChunk(pt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iterator.
|
||||
*
|
||||
|
@ -20,6 +20,8 @@
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -74,4 +76,10 @@ public interface Region extends Iterable<Vector> {
|
||||
* @param change
|
||||
*/
|
||||
public void contract(Vector change);
|
||||
/**
|
||||
* Get a list of chunks.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Vector2D> getChunks();
|
||||
}
|
||||
|
Reference in New Issue
Block a user