Skip to content

Commit

Permalink
Reimplement legacy structure xml parsing logic (PGMDev#1098)
Browse files Browse the repository at this point in the history
Signed-off-by: KingSimon <[email protected]>
  • Loading branch information
KingOfSquares authored and calcastor committed Nov 14, 2022
1 parent 31a4c2f commit 189b6df
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/src/main/java/tc/oc/pgm/structure/StructureModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import tc.oc.pgm.regions.BlockBoundedValidation;
import tc.oc.pgm.regions.RegionParser;
import tc.oc.pgm.snapshot.SnapshotMatchModule;
import tc.oc.pgm.util.Version;
import tc.oc.pgm.util.xml.InvalidXMLException;
import tc.oc.pgm.util.xml.Node;
import tc.oc.pgm.util.xml.XMLUtils;
Expand Down Expand Up @@ -61,7 +62,8 @@ public static class Factory implements MapModuleFactory<StructureModule> {
@Override
public StructureModule parse(MapFactory factory, Logger logger, Document doc)
throws InvalidXMLException {
if (factory.getProto().isOlderThan(MapProtos.FILTER_FEATURES)) return null;
Version proto = factory.getProto();
if (proto.isOlderThan(MapProtos.FILTER_FEATURES)) return null;

FilterParser filters = factory.getFilters();
RegionParser regions = factory.getRegions();
Expand Down Expand Up @@ -95,9 +97,15 @@ public StructureModule parse(MapFactory factory, Logger logger, Document doc)
final StructureDefinition structure =
structures.get(el.getAttribute("structure").getValue());

Filter trigger =
filters.parseRequiredProperty(el, "trigger", DynamicFilterValidation.MATCH);
Filter filter = filters.parseProperty(el, "filter", StaticFilter.ALLOW);
Filter trigger, filter;
if (proto.isOlderThan(MapProtos.DYNAMIC_FILTERS)) {
// Legacy maps use "filter" as their trigger
trigger = filters.parseRequiredProperty(el, "filter", DynamicFilterValidation.MATCH);
filter = StaticFilter.ALLOW;
} else {
trigger = filters.parseRequiredProperty(el, "trigger", DynamicFilterValidation.MATCH);
filter = filters.parseProperty(el, "filter", StaticFilter.ALLOW);
}

DynamicStructureDefinition definition =
new DynamicStructureDefinition(id, structure, trigger, filter, position, offset);
Expand Down

0 comments on commit 189b6df

Please sign in to comment.