@Logging(POSITION)
@CommandPermissions("worldedit.selection.chunk")
public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
final Vector min;
final Vector max;
final World world = player.getWorld();
if (args.hasFlag('s')) {
Region region = session.getSelection(world);
final Vector2D min2D = ChunkStore.toChunk(region.getMinimumPoint());
final Vector2D max2D = ChunkStore.toChunk(region.getMaximumPoint());
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
max = new Vector(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
player.print("Chunks selected: ("
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")");
} else {
final Vector2D min2D;
if (args.argsLength() == 1) {
// coords specified
String[] coords = args.getString(0).split(",");
if (coords.length != 2) {
throw new InsufficientArgumentsException("Invalid coordinates specified.");
}
int x = Integer.parseInt(coords[0]);
int z = Integer.parseInt(coords[1]);
Vector2D pos = new Vector2D(x, z);
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toVector());
} else {
// use player loc
min2D = ChunkStore.toChunk(player.getBlockIn());
}
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
max = min.add(15, world.getMaxY(), 15);
player.print("Chunk selected: "
+ min2D.getBlockX() + ", " + min2D.getBlockZ());
}