Skip to content

Make sure no blocks are placed when deleting a plot - #4818

Open
florianreuth wants to merge 5 commits into
IntellectualSites:mainfrom
florianreuth:bugfix/remove-placed-blocks
Open

Make sure no blocks are placed when deleting a plot#4818
florianreuth wants to merge 5 commits into
IntellectualSites:mainfrom
florianreuth:bugfix/remove-placed-blocks

Conversation

@florianreuth

Copy link
Copy Markdown
Contributor

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

  • Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • Ensure that the pull request title represents the desired changelog entry.
  • New public fields and methods are annotated with @since TODO.
  • I read and followed the contribution guidelines.

Fixes IntellectualSites#4794

Signed-off-by: FlorianMichael <git@florianmichael.de>
Comment thread Core/src/main/java/com/plotsquared/core/command/Delete.java Outdated
… on errors

Signed-off-by: Florian Reuth <git@florianreuth.de>
Comment thread Core/src/main/java/com/plotsquared/core/command/Delete.java Outdated
Comment thread Core/src/main/java/com/plotsquared/core/command/Delete.java Outdated
Comment thread Core/src/main/java/com/plotsquared/core/command/Delete.java
@NotMyFault
NotMyFault requested a review from dordsor21 April 2, 2026 14:36
Signed-off-by: Florian Reuth <git@florianreuth.de>
@NotMyFault
NotMyFault requested a review from a team April 12, 2026 17:16
@NotMyFault

Copy link
Copy Markdown
Member

@dordsor21 might taking a look?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pendingDelete plot meta marker during /plot delete execution and clear it on completion/failure.
  • Cancel BlockPlaceEvent and BlockBreakEvent when the current plot has pendingDelete metadata 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.

Comment thread Core/src/main/java/com/plotsquared/core/command/Delete.java
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");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blocks placed during /plot delete confirmation remain after plot is deleted

4 participants