package in.twizmwaz.cardinal.module.modules.regions.parsers;

import in.twizmwaz.cardinal.module.modules.regions.RegionParser;
import org.bukkit.util.Vector;
import org.jdom2.Element;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CuboidParser extends RegionParser {

    private final Vector min, max;
    
    public CuboidParser(Element element) {
        super(element.getAttributeValue("name"));
        List<String> values = new ArrayList<>();
        values.addAll(Arrays.asList(element.getAttributeValue("min").contains(",") ? 
                element.getAttributeValue("min").trim().split(",") : element.getAttributeValue("min").trim().split(" ")));
        values.addAll(Arrays.asList(element.getAttributeValue("max").trim().replaceAll(" ", ",").split(",")));
        for (String string : values) {
            values.set(values.indexOf(string), string.trim());
            if (string.equalsIgnoreCase("oo")) values.set(values.indexOf(string), "256");
            if (string.equalsIgnoreCase("-oo")) values.set(values.indexOf(string), "0");
        }
        this.min = new Vector(Double.parseDouble(values.get(0)), Double.parseDouble(values.get(1)), Double.parseDouble(values.get(2)));
        this.max = new Vector(Double.parseDouble(values.get(3)), Double.parseDouble(values.get(4)), Double.parseDouble(values.get(5)));
    }

    public Vector getMin() {
        return min;
    }

    public Vector getMax() {
        return max;
    }
}

@@ -120,16 +120,59 @@
 Parser;%0A
+import in.twizmwaz.cardinal.util.NumUtils;%0A
 import o
@@ -956,187 +956,8 @@
 ));%0A
-            if (string.equalsIgnoreCase(%22oo%22)) values.set(values.indexOf(string), %22256%22);%0A            if (string.equalsIgnoreCase(%22-oo%22)) values.set(values.indexOf(string), %220%22);%0A
     
@@ -984,38 +984,40 @@
 in = new Vector(
-Double
+NumUtils
 .parseDouble(val
@@ -1025,30 +1025,32 @@
 es.get(0)), 
-Double
+NumUtils
 .parseDouble
@@ -1062,30 +1062,32 @@
 es.get(1)), 
-Double
+NumUtils
 .parseDouble
@@ -1134,22 +1134,24 @@
  Vector(
-Double
+NumUtils
 .parseDo
@@ -1167,30 +1167,32 @@
 es.get(3)), 
-Double
+NumUtils
 .parseDouble
@@ -1208,22 +1208,24 @@
 et(4)), 
-Double
+NumUtils
 .parseDo

Fix cuboid regions not extending all the way to negative infinity