From 2b54daacb3d40370dc05eb55cda4090473d68dba Mon Sep 17 00:00:00 2001 From: Legends11 <235496468+tickwarden@users.noreply.github.com> Date: Sun, 2 Aug 2026 08:15:05 +0000 Subject: [PATCH] . --- migrate.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/migrate.py b/migrate.py index bb420f8..bac9d65 100644 --- a/migrate.py +++ b/migrate.py @@ -690,8 +690,21 @@ def step_15_post_fixes(): # set or left as bare comments -- neither approach reflected what # the module actually touches, and both could leave init/cleanup # empty or referencing files that don't exist. - objective_pattern = re.compile(r'\bscoreboard\s+(?:objectives\s+add|players\s+\S+)\s+\S+\s+(\S+)') objective_def_pattern = re.compile(r'\bscoreboard\s+objectives\s+add\s+(\S+)\s+\S+') + # `scoreboard players ...` + # -- the objective is the token right after the target selector. + objective_use_pattern = re.compile( + r'\bscoreboard\s+players\s+(?:set|add|remove|get|enable|operation|reset)\s+\S+\s+(\S+)' + ) + + def _clean_objective(raw_obj): + # Reject macro placeholders (e.g. $(objective), $(pb_obj)) -- these + # are resolved at runtime per-call and aren't a fixed objective + # name this module can pre-declare. + if not raw_obj or raw_obj.startswith("$("): + return None + return raw_obj + # Captures the storage id as a single colon-joined token (ns:root) and, # if present, the following NBT key as a separate token -- this matches # real syntax: `data modify storage set value ...`. @@ -719,7 +732,13 @@ def scan_module_usage(m, ns): if stripped.startswith("#"): continue for om in objective_def_pattern.finditer(line): - objectives.add(om.group(1)) + obj = _clean_objective(om.group(1)) + if obj: + objectives.add(obj) + for om in objective_use_pattern.finditer(line): + obj = _clean_objective(om.group(1)) + if obj: + objectives.add(obj) for sm in storage_pattern.finditer(line): storages.add((sm.group(1), _clean_key(sm.group(2)))) return sorted(objectives), sorted(storages, key=lambda t: (t[0], t[1] or "")) @@ -1017,4 +1036,4 @@ def main(): Logger.banner("MIGRATION PIPELINE COMPLETED SUCCESSFULLY") if __name__ == "__main__": - main() + main() \ No newline at end of file