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

import in.twizmwaz.cardinal.module.modules.filter.FilterParser;
import in.twizmwaz.cardinal.util.NumUtils;
import org.jdom2.Element;

public class KillstreakFilterParser extends FilterParser {

    private int min, max, count;
    private boolean repeat;

    public KillstreakFilterParser(final Element element) {
        super(element);
        try {
            this.min = NumUtils.parseInt(element.getAttributeValue("min"));
        } catch (NumberFormatException e) {
            this.min = -1;
        }
        try {
            this.max = NumUtils.parseInt(element.getAttributeValue("max"));
        } catch (NumberFormatException e) {
            this.max = -1;
        }
        try {
            this.count = NumUtils.parseInt(element.getAttributeValue("count"));
        } catch (NumberFormatException e) {
            this.count = -1;
        }
        try {
            this.repeat = Boolean.parseBoolean(element.getAttributeValue("repeat"));
        } catch (NumberFormatException e) {
            this.repeat = false;
        }
    }

    public int getMin() {
        return min;
    }

    public int getMax() {
        return max;
    }

    public int getCount() {
        return count;
    }

    public boolean isRepeat() {
        return repeat;
    }

}

@@ -394,36 +394,85 @@
 ment);%0A        t
-ry %7B
+his.min = element.getAttributeValue(%22min%22) != null ? 
 %0A            thi
@@ -468,26 +468,19 @@
         
-this.min =
+   
  NumUtil
@@ -523,16 +523,21 @@
 (%22min%22))
+ : -1
 ;%0A      
@@ -542,88 +542,69 @@
     
-%7D catch (NumberFormatException e) %7B%0A            this.min = -1;%0A        %7D
+this.max = element.getAttributeValue(%22max%22) != null ?
 %0A       
  try
@@ -595,39 +595,32 @@
 ll ?%0A       
- try %7B%0A
         
     this.max
@@ -607,30 +607,16 @@
         
-    this.max =
  NumUtil
@@ -659,16 +659,21 @@
 (%22max%22))
+ : -1
 ;%0A      
@@ -678,80 +678,65 @@
     
-%7D catch (NumberFormatException e) %7B%0A            this.max = -1;%0A        %7D
+this.count = element.getAttributeValue(%22count%22) != null ?
 %0A   
@@ -744,38 +744,15 @@
     
-try %7B%0A
+ 
       
-      this.count =
  Num
@@ -805,278 +805,143 @@
 t%22))
-;%0A        %7D catch (NumberFormatException e) %7B%0A            this.count = -1;%0A        %7D%0A        try %7B%0A            this.repeat = Boolean.parseBoolean(element.getAttributeValue(%22repeat%22));%0A        %7D catch (NumberFormatException e) %7B%0A            this.repeat = false;%0A        %7D
+ : -1;%0A        this.repeat = element.getAttributeValue(%22repeat%22) != null && NumUtils.parseBoolean(element.getAttributeValue(%22repeat%22));
 %0A   

Fix an NPE when parsing killstreaks