Make sure no blocks are placed when deleting a plot - #4818
Conversation
Fixes IntellectualSites#4794 Signed-off-by: FlorianMichael <git@florianmichael.de>
… on errors Signed-off-by: Florian Reuth <git@florianreuth.de>
Signed-off-by: Florian Reuth <git@florianreuth.de>
Signed-off-by: Florian Reuth <git@florianreuth.de>
|
@dordsor21 might taking a look? |
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent players from modifying plots while a plot deletion is in progress by marking plots with temporary metadata and cancelling Bukkit block place/break events while that metadata is present (intended to address issue #4794).
Changes:
- Add a temporary
pendingDeleteplot meta marker during/plot deleteexecution and clear it on completion/failure. - Cancel
BlockPlaceEventandBlockBreakEventwhen the current plot haspendingDeletemetadata set.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Core/src/main/java/com/plotsquared/core/command/Delete.java | Adds/clears pendingDelete meta around the delete operation lifecycle. |
| Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java | Cancels block place/break when pendingDelete meta is present on the plot. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(value)))) | ||
| ); | ||
| try { | ||
| // Clear pending delete metadata now that deletion is actually starting |
| if (plot.getRunning() > 0) { | ||
| for (Plot connectedPlot : plots) { | ||
| connectedPlot.deleteMeta("pendingDelete"); | ||
| } |
There was a problem hiding this comment.
theoretically a player could run delete twice and remove the meta in this case
| // ... or if something went wrong | ||
| for (Plot connectedPlot : plots) { | ||
| connectedPlot.deleteMeta("pendingDelete"); | ||
| } |
There was a problem hiding this comment.
We remove the meta at the start of the try block, so this is needless. Error handling I meant in the deletion method itself - we need to make sure we're recovering properly (if this requires architectural changes/changes the method signatures so be it)
Overview
Fixes #4794
Description
When starting the deletion process, a plot meta is set. The plot meta will be unset once the plot deletion is finished and during it being set block place/break events will be cancelled.
Submitter Checklist
@since TODO.