plugins/tools/verify-arrakis-terrain.py
unimatrixgit 78dea2fb77
All checks were successful
DuneRealms Resourcepack CI / resourcepack (push) Successful in 2m16s
DuneRealms Plugin CI / plugins (push) Successful in 2m58s
Rebuild Arrakis strata and bloom attempts with guarded world reset
2026-11-29 14:09:20 +01:00

28 lines
1.3 KiB
Python

"""Read-only ABI/resource verification against the reviewed active Arrakis Terrain contract."""
import hashlib
import json
from pathlib import Path
import sys
import zipfile
sys.path.insert(0, str(Path(__file__).resolve().parent))
from plugin_backend_abi import jar_classes
def verify(jar, contract):
classes = jar_classes(jar)
for name, old in contract['classes'].items():
if name not in classes: raise ValueError('Missing retained Terrain class: ' + name)
for kind in ('methods', 'fields'):
for member in old[kind]:
if member not in classes[name][kind]: raise ValueError('Missing retained Terrain API: ' + name + ':' + str(member))
with zipfile.ZipFile(jar) as archive:
for name, expected in contract['resources'].items():
payload = archive.read(name)
if isinstance(expected, dict):
payload = json.dumps(json.loads(payload), sort_keys=True, separators=(',', ':')).encode()
expected = expected['canonicalSha256']
if hashlib.sha256(payload).hexdigest() != expected: raise ValueError('Retained gameplay resource changed: ' + name)
return {'retainedClasses': len(contract['classes']), 'retainedResources': len(contract['resources'])}
if __name__ == '__main__': print(json.dumps(verify(sys.argv[1], json.loads(Path(sys.argv[2]).read_text()))))