diff --git a/core/src/main/java/tc/oc/pgm/filters/FilterParser.java b/core/src/main/java/tc/oc/pgm/filters/FilterParser.java index 6703e2348f..138caf2e6a 100644 --- a/core/src/main/java/tc/oc/pgm/filters/FilterParser.java +++ b/core/src/main/java/tc/oc/pgm/filters/FilterParser.java @@ -15,7 +15,6 @@ import org.jdom2.Element; import tc.oc.pgm.api.filter.Filter; import tc.oc.pgm.api.map.factory.MapFactory; -import tc.oc.pgm.api.match.MatchPhase; import tc.oc.pgm.api.player.PlayerRelation; import tc.oc.pgm.classes.ClassModule; import tc.oc.pgm.classes.PlayerClass; @@ -481,28 +480,20 @@ public Filter parseMatchFinished(Element el) throws InvalidXMLException { private Filter parseMatchPhaseFilter(String matchState, Element el) throws InvalidXMLException { - MatchPhase matchPhase = null; - switch (matchState) { case "running": - matchPhase = MatchPhase.RUNNING; - break; + return MatchPhaseFilter.RUNNING; case "finished": - matchPhase = MatchPhase.FINISHED; - break; + return MatchPhaseFilter.FINISHED; case "starting": - matchPhase = MatchPhase.STARTING; - break; + return MatchPhaseFilter.STARTING; case "idle": - matchPhase = MatchPhase.IDLE; - break; + return MatchPhaseFilter.IDLE; case "started": - return AnyFilter.of( - new MatchPhaseFilter(MatchPhase.RUNNING), new MatchPhaseFilter(MatchPhase.FINISHED)); + return MatchPhaseFilter.STARTED; } - if (matchPhase == null) throw new InvalidXMLException("Invalid or no match state found", el); - return new MatchPhaseFilter(matchPhase); + throw new InvalidXMLException("Invalid or no match state found", el); } // Methods for parsing QueryModifiers diff --git a/core/src/main/java/tc/oc/pgm/filters/MatchPhaseFilter.java b/core/src/main/java/tc/oc/pgm/filters/MatchPhaseFilter.java index b85bc53ad6..c482a25eec 100644 --- a/core/src/main/java/tc/oc/pgm/filters/MatchPhaseFilter.java +++ b/core/src/main/java/tc/oc/pgm/filters/MatchPhaseFilter.java @@ -1,10 +1,19 @@ package tc.oc.pgm.filters; +import tc.oc.pgm.api.filter.Filter; import tc.oc.pgm.api.filter.query.MatchQuery; import tc.oc.pgm.api.match.MatchPhase; public class MatchPhaseFilter extends TypedFilter { + public static final MatchPhaseFilter RUNNING = new MatchPhaseFilter(MatchPhase.RUNNING); + public static final MatchPhaseFilter FINISHED = new MatchPhaseFilter(MatchPhase.FINISHED); + public static final MatchPhaseFilter STARTING = new MatchPhaseFilter(MatchPhase.STARTING); + public static final MatchPhaseFilter IDLE = new MatchPhaseFilter(MatchPhase.IDLE); + public static final Filter STARTED = + AnyFilter.of( + new MatchPhaseFilter(MatchPhase.RUNNING), new MatchPhaseFilter(MatchPhase.FINISHED)); + private final MatchPhase matchPhase; public MatchPhaseFilter(MatchPhase matchPhase) {