Disable legacy manual plot clearing in existing worlds
All checks were successful
Unused Vendor Settings Operations Build / unused-vendor-settings (push) Successful in 6s
DuneRealms Plugin CI / plugins (push) Successful in 2m49s

This commit is contained in:
unimatrixgit 2026-12-02 12:33:35 +01:00
commit 5d727d7f59
2 changed files with 10 additions and 9 deletions

View file

@ -63,15 +63,16 @@ def digest(data):
def patch_world(data):
deletion = rb'(?m)^usingPlotManagementDelete=(true)(?=\r?$)'
if len(re.findall(rb'(?m)^usingPlotManagementDelete=', data)) != 1:
raise ValueError('Expected exactly one Towny world block-deletion field')
if len(re.findall(rb'(?m)^usingPlotManagementRevert=false(?=\r?$)', data)) != 1:
raise ValueError('Expected Towny plot regeneration already disabled')
after, count = re.subn(deletion, b'usingPlotManagementDelete=false', data)
if count != 1:
raise ValueError('Expected Towny world block deletion still enabled')
return after
for field in (b'usingPlotManagementDelete', b'usingPlotManagementMayorDelete'):
prefix = rb'(?m)^' + field + b'='
if len(re.findall(prefix, data)) != 1:
raise ValueError(f'Expected one Towny world field: {field.decode()}')
data, count = re.subn(prefix + rb'true(?=\r?$)', field + b'=false', data)
if count != 1:
raise ValueError(f'Expected enabled Towny world field: {field.decode()}')
return data
def read_pinned(path, pin):

View file

@ -42,10 +42,10 @@ class UnusedVendorSettingsTest(unittest.TestCase):
self.assertTrue(all(re.fullmatch(r'[0-9a-f]{64}', sha)
for server in worlds.values() for sha in server.values()))
def test_world_cleanup_changes_only_the_unclaim_block_deletion_flag(self):
def test_world_cleanup_changes_only_the_two_block_deletion_flags(self):
source = (b'usingTowny=true\r\nusingPlotManagementDelete=true\r\n'
b'usingPlotManagementRevert=false\r\nusingPlotManagementMayorDelete=true')
expected = source.replace(b'usingPlotManagementDelete=true', b'usingPlotManagementDelete=false')
expected = source.replace(b'Delete=true', b'Delete=false')
self.assertEqual(MODULE['patch_world'](source), expected)
with self.assertRaises(ValueError):
MODULE['patch_world'](source.replace(b'Revert=false', b'Revert=true'))