package me.jacobcrofts.simplestructureloader.util;

import java.util.HashMap;
import java.util.Map;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;

public class Selection {
	
	private Location left;
	private Location right;
	
	public Selection() {
		
	}
	
	public Location getLeftClickLocation() {
		return this.left;
	}
	
	public Location getRightClickLocation() {
		return this.right;
	}
	
	public void setLeftClickLocation(Location location) {
		this.left = location;
	}
	
	public void setRightClickLocation(Location location) {
		this.right = location;
	}
	
	public Map<Location, Block> getLocationsAndBlocks() {
		Map<Location, Block> blockData = new HashMap<Location, Block>();
		
		int xMin = Math.min(left.getBlockX(), right.getBlockX());
		int xMax = Math.max(left.getBlockX(), right.getBlockX());
		int yMin = Math.min(left.getBlockY(), right.getBlockY());
		int yMax = Math.max(left.getBlockY(), right.getBlockY());
		int zMin = Math.min(left.getBlockZ(), right.getBlockZ());
		int zMax = Math.max(left.getBlockZ(), right.getBlockZ());
		
		World world = left.getWorld();
		
		for (int x = xMin; x <= xMax; x++) {
			for (int y = yMin; y <= yMax; y++) {
				for (int z = zMin; z <= zMax; z++) {
					Location l = new Location(world, x, y, z);
					blockData.put(l, l.getBlock());
				}
			}
		}
		
		return blockData;
	}

}

@@ -62,23 +62,25 @@
 va.util.
-HashMap
+ArrayList
 ;%0Aimport
@@ -90,19 +90,20 @@
 va.util.
-Map
+List
 ;%0A%0Aimpor
@@ -180,16 +180,85 @@
 k.Block;
+%0Aimport org.json.simple.JSONArray;%0Aimport org.json.simple.JSONObject;
 %0A%0Apublic
@@ -677,71 +677,41 @@
 lic 
-Map%3CLocation, Block%3E getLocationsAndBlocks() %7B%0A%09%09Map%3CLocation, 
+List%3CBlock%3E getBlocks() %7B%0A%09%09List%3C
 Bloc
@@ -733,26 +733,18 @@
 new 
-HashMap%3CLocation, 
+ArrayList%3C
 Bloc
@@ -1338,16 +1338,359 @@
 ata.
-put(l, l
+add(l.getBlock());%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return blockData;%0A%09%7D%0A%09%0A%09@SuppressWarnings(%7B %22deprecation%22, %22unchecked%22 %7D)%0A%09public JSONArray toJSON() %7B%0A%09%09JSONArray blockDataArray = new JSONArray();%0A%09%09%0A%09%09List%3CBlock%3E blocks = this.getBlocks();%0A%09%09%0A%09%09for (Block block : blocks) %7B%0A%09%09%09JSONObject blockJSON = new JSONObject();%0A%09%09%09blockJSON.put(%22x%22, block.getLocation()
 .get
@@ -1690,32 +1690,33 @@
 n().getBlock
+X
 ());%0A%09%09%09
 %09%7D%0A%09%09%09%7D%0A%09%09%7D%0A
@@ -1695,39 +1695,271 @@
 etBlockX());%0A%09%09%09
-%09%7D%0A%09%09%09%7D
+blockJSON.put(%22y%22, block.getLocation().getBlockY());%0A%09%09%09blockJSON.put(%22z%22, block.getLocation().getBlockZ());%0A%09%09%09blockJSON.put(%22type%22, block.getType().toString());%0A%09%09%09blockJSON.put(%22data%22, block.getData());%0A%09%09%09blockDataArray.add(blockJSON);
 %0A%09%09%7D%0A%09%09%0A%09%09return
@@ -1964,20 +1964,25 @@
 rn blockData
+Array
 ;%0A%09%7D%0A%0A%7D%0A

Add feature: Selection#toJSON