@@ -185,6 +185,7 @@ unzip -p "$plugin_jar" config.yml > "$run_directory/plugins/InteractionVisualize
185185
186186python3 - " $run_directory /plugins/InteractionVisualizer/config.yml" " $scenario " " $variant " " $ab_factor " << 'PY '
187187from pathlib import Path
188+ import re
188189import sys
189190
190191path = Path(sys.argv[1])
@@ -200,20 +201,26 @@ def replace_once(old: str, new: str) -> None:
200201 raise SystemExit(f"Expected one config token {old!r}, found {count}")
201202 text = text.replace(old, new, 1)
202203
204+ def replace_boolean_once(prefix: str, value: bool) -> None:
205+ global text
206+ pattern = re.compile(rf"(?m)^{re.escape(prefix)}(?:true|false)$")
207+ replacement = f"{prefix}{str(value).lower()}"
208+ text, count = pattern.subn(replacement, text, count=1)
209+ if count != 1:
210+ raise SystemExit(
211+ f"Expected one boolean config token with prefix {prefix!r}, found {count}"
212+ )
213+
203214packet_only = scenario == "visibility-return" or (
204215 scenario in {"static-steady", "static-spawn"} and variant == "B"
205216)
206217visibility_limit = scenario.startswith("visibility-") and variant == "B"
207218event_driven = scenario.startswith("block-") and (
208219 ab_factor == "legacy-text-component-cache" or variant == "B"
209220)
210- replace_once(" PacketOnlyStatic: false",
211- f" PacketOnlyStatic: {str(packet_only).lower()}")
212- replace_once(" Enabled: false\n BucketSize: 128\n RestorePerTick: 32",
213- f" Enabled: {str(visibility_limit).lower()}\n"
214- " BucketSize: 128\n RestorePerTick: 32")
215- replace_once(" EventDriven: false",
216- f" EventDriven: {str(event_driven).lower()}")
221+ replace_boolean_once(" PacketOnlyStatic: ", packet_only)
222+ replace_boolean_once(" Enabled: ", visibility_limit)
223+ replace_boolean_once(" EventDriven: ", event_driven)
217224replace_once(" Updater: true", " Updater: false")
218225replace_once(" DownloadLanguageFiles: true", " DownloadLanguageFiles: false")
219226path.write_text(text, encoding="utf-8", newline="\n")
0 commit comments