@@ -211,18 +211,27 @@ private void addFlagsToMap(SiegeMap map, MapTemplateMetadata metadata) {
211211 .map (region -> {
212212 NbtCompound data = region .getData ();
213213
214- String id = data .getString ("id" );
215- SiegeFlag flag = flags .get (id );
214+ String gateId = data .getString ("id" );
215+ String flagIdRaw = data .getString ("flag" );
216+ final String flagId = flagIdRaw .isEmpty () ? gateId : flagIdRaw ;
217+
218+ SiegeFlag flag = flags .get (flagId );
216219 if (flag == null ) {
217- throw new GameOpenException (Text .literal ("Gate missing flag with id '" + id + "'!" ));
220+ var text = Text .literal (String .format ("Gate (id '%s') missing flag with id '%s'!" , gateId , flagId ));
221+
222+ if (flagIdRaw .isEmpty ()) {
223+ text = text .append (Text .literal ("\n Note: flag id was implicitly defined as the gate id, as `flag` was missing in data." ));
224+ }
225+
226+ throw new GameOpenException (text );
218227 }
219228
220229 TemplateRegion portcullisRegion = metadata .getRegions ("portcullis" )
221- .filter (r -> id .equalsIgnoreCase (r .getData ().getString ("id" )))
230+ .filter (r -> gateId .equalsIgnoreCase (r .getData ().getString ("id" )))
222231 .findFirst ()
223232 .orElseThrow (() -> {
224- Siege .LOGGER .error ("Gate \" {}\" missing portcullis!" , id );
225- return new GameOpenException (Text .literal ("Gate missing portcullis!" ));
233+ Siege .LOGGER .error ("Gate \" {}\" missing portcullis!" , gateId );
234+ return new GameOpenException (Text .literal (String . format ( "Gate (id '%s') missing portcullis!" , gateId ) ));
226235 });
227236
228237 NbtCompound portcullisData = portcullisRegion .getData ();
@@ -241,13 +250,13 @@ private void addFlagsToMap(SiegeMap map, MapTemplateMetadata metadata) {
241250 }
242251
243252 BlockBounds brace = metadata .getRegions ("gate_brace" )
244- .filter (r -> id .equalsIgnoreCase (r .getData ().getString ("id" )))
253+ .filter (r -> flagId .equalsIgnoreCase (r .getData ().getString ("id" )))
245254 .map (TemplateRegion ::getBounds )
246255 .findFirst ()
247256 .orElse (null );
248257
249258 SiegeGate gate = new SiegeGate (flag , region .getBounds (), portcullisRegion .getBounds (), brace , retractHeight , repairHealthThreshold , maxHealth );
250- flag .gate = gate ;
259+ flag .gates . add ( gate ) ;
251260 return gate ;
252261 })
253262 .collect (Collectors .toList ());
0 commit comments