From 87380f5124c12c77dcb229183828ba38dc97ec69 Mon Sep 17 00:00:00 2001 From: KingSimon <19822231+KingOfSquares@users.noreply.github.com> Date: Tue, 8 Nov 2022 10:21:52 +0100 Subject: [PATCH] Reimplement legacy structure xml parsing logic Signed-off-by: KingSimon <19822231+KingOfSquares@users.noreply.github.com> --- .../tc/oc/pgm/structure/StructureModule.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/structure/StructureModule.java b/core/src/main/java/tc/oc/pgm/structure/StructureModule.java index 9b51cf7ea7..c1d8942de9 100644 --- a/core/src/main/java/tc/oc/pgm/structure/StructureModule.java +++ b/core/src/main/java/tc/oc/pgm/structure/StructureModule.java @@ -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; @@ -61,7 +62,8 @@ public static class Factory implements MapModuleFactory { @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(); @@ -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);