Ledger
Ledger copied to clipboard
Log Sign Editing and Waxing
Implements #214
Adds logging for sign (and hanging sign) text editing and item-based interactions including waxing, dyeing, ink, and glow ink, with rollback support.
Editing signs mutates the block entity instance which makes it difficult to properly log for rollbacks. My solution is a bit of a hack that captures the old block entity data by copying the NBT data into a new block entity instance and then logging that copy as the old block entity. This seems to me to be the only way to do this, but I would definitely prefer something that doesn't involve direct NBT copying like this.
Currently, this does not seem to work with restoring. However, when I looked into it, restoring block entity data seems to just be a missing feature in Ledger. Perhaps another PR could implement this, or I could look into creating a new action type for sign editing. Especially for text editing, it might be nice to see something like "old text" -> "new text" in the result, similar to what happens when you wax a copper block. The sign text might be a bit long for a single line in a chat message, though.
There is also an issue where rolling back a sign does not cause it to immediately update its appearance. Its data does indeed change, and you can verify by checking with /data
or by rejoining the server. I assume this is related to another issue where signs also appear blank after inspecting them with left-click. It might be fixable by sending some sort of block entity update packet to nearby players on restore, but that might incur some additional cost of iterating over all players to find the nearby ones many times (and of course, the cost of actually sending those packets).
Let me know what you think :D