feat(undo): restore the latest felled tree safely

This commit is contained in:
dmg
2026-08-11 17:32:41 -04:00
parent 17f1631b96
commit 8c7c008ca0
10 changed files with 521 additions and 19 deletions
@@ -2,7 +2,7 @@
type: User Story
title: "US-005: Undo the last felled tree"
description: Safely restore the player's most recent automatic felling without creating replacement materials.
status: backlog
status: done
---
# US-005: Undo the last felled tree
@@ -11,21 +11,21 @@ As a **player**, I want to undo my latest automatically felled tree so that I ca
## Acceptance criteria
- [ ] `/treefeller undo` targets only the issuing player's most recent automatic felling.
- [ ] An undo record contains only blocks successfully removed by the operation, including the initiating trunk block when its original state can be captured safely.
- [ ] Each record retains the world, block coordinates, original block material, and original block data needed to restore orientation and other supported state.
- [ ] Only one undo record is retained per player; a later felling replaces the earlier record after the later operation has removed at least one eligible tree block.
- [ ] An undo remains available for six minutes after the felling by default, with a configurable duration.
- [ ] Undo performs a complete preflight before changing the world or inventory.
- [ ] Preflight requires every target world and chunk to be available and every target position to remain safely restorable; an occupied or otherwise unsafe position fails the whole undo.
- [ ] Preflight calculates the exact replacement materials required to reconstruct all recorded trunk states and requires those aggregate materials in the issuing player's inventory.
- [ ] If inventory is insufficient, no item or block changes occur and the error lists every missing material with its missing quantity.
- [ ] On success, required materials are removed exactly once and all recorded blocks are restored as one logical operation.
- [ ] If an unexpected restoration failure occurs after preflight, the implementation avoids a silent partial result and reports the recovery action needed to administrators.
- [ ] A successful undo consumes the record so that it cannot be repeated.
- [ ] An expired, absent, already-used, or invalid undo produces a clear message and makes no changes.
- [ ] Undo restores trunk blocks only; it does not restore foliage, caps, roots, drops, experience, or axe durability.
- [ ] Undo has a distinct player permission and never grants access to `/treefelleradmin`.
- [x] `/treefeller undo` targets only the issuing player's most recent automatic felling.
- [x] An undo record contains only blocks successfully removed by the operation, including the initiating trunk block when its original state can be captured safely.
- [x] Each record retains the world, block coordinates, original block material, and original block data needed to restore orientation and other supported state.
- [x] Only one undo record is retained per player; a later felling replaces the earlier record after the later operation has removed at least one eligible tree block.
- [x] An undo remains available for six minutes after the felling by default, with a configurable duration.
- [x] Undo performs a complete preflight before changing the world or inventory.
- [x] Preflight requires every target world and chunk to be available and every target position to remain safely restorable; an occupied or otherwise unsafe position fails the whole undo.
- [x] Preflight calculates the exact replacement materials required to reconstruct all recorded trunk states and requires those aggregate materials in the issuing player's inventory.
- [x] If inventory is insufficient, no item or block changes occur and the error lists every missing material with its missing quantity.
- [x] On success, required materials are removed exactly once and all recorded blocks are restored as one logical operation.
- [x] If an unexpected restoration failure occurs after preflight, the implementation avoids a silent partial result and reports the recovery action needed to administrators.
- [x] A successful undo consumes the record so that it cannot be repeated.
- [x] An expired, absent, already-used, or invalid undo produces a clear message and makes no changes.
- [x] Undo restores trunk blocks only; it does not restore foliage, caps, roots, drops, experience, or axe durability.
- [x] Undo has a distinct player permission and never grants access to `/treefelleradmin`.
## Related