package leigh.minecraft.worldguard;

import leigh.mecha.json.JSONObject;
import leigh.mecha.log.MechaLogger;
import leigh.mecha.log.MechaLoggerFactory;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class LotRepairApp {
    private static final MechaLogger logger = MechaLoggerFactory.getLogger(LotRepairApp.class);

    public static void main(String[] args) throws IOException {
        InputStream is = new FileInputStream("regions.json");
        String json = IOUtils.toString(is);

        JSONObject obj = new JSONObject(json);

        //     logger.info("Read keys: {}", obj.keySet());

        int i = 400;

        JSONObject regions = obj.getJSONObject("regions");
        for (String regionId : regions.keySet()) {
            //    logger.info("Reading: {}", regionId);
            if (regionId.equals("__global__") || regionId.startsWith("ctl-")) continue;
            JSONObject region = regions.getJSONObject(regionId);

            /*
            JSONObject region = regions.getJSONObject(regionId);
            JSONObject min = region.getJSONObject("min");
            JSONObject max = region.getJSONObject("max");

            int minx = min.getInt("x");
            int maxx = max.getInt("x");
            int minz = min.getInt("z");
            int maxz = max.getInt("z");

            if (minx < 0 || maxx < 0) {
                min.put("x", minx - 1);
                max.put("x", maxx - 1);
            }

            if (minz < 0 || maxz < 0) {
                min.put("z", minz - 1);
                max.put("z", maxz - 1);
            }

             */
        }

        System.out.println(obj.toString());
    }

}
