Skip to content

fix: block edits on a plot while a plot operation is running - #4973

Open
TheMeinerLP wants to merge 1 commit into
IntellectualSites:mainfrom
TheMeinerLP:fix/block-edits-during-plot-operation
Open

TheMeinerLP wants to merge 1 commit into
IntellectualSites:mainfrom
TheMeinerLP:fix/block-edits-during-plot-operation

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Member

Overview

Fixes #3056.

When two plots are merged, PlotSquared marks the road between them as part of the plot first and replaces the road blocks afterwards, in the queue. For a few ticks the owner may build on the old road. With a fast enough pickaxe they break the road and wall blocks in that window and keep the drops.

This was reproduced in game on 7.6.1, both with WorldEdit and with FAWE, through /plot merge and through /plot auto 2,2: with Efficiency IV or higher, Efficiency III with Haste II, or the instabreak flag (which needs no enchantment and is part of the basic flag permissions). Pistons and TNT pulled or blew road and wall blocks out of the same window.

What changed

While a plot operation runs on a plot, the plot is marked as running until the queue has finished: for /plot merge, for the merge part of a multi-plot /plot auto, and for the existing operations that already used the marker. During that time:

  • placing and breaking blocks is refused with the existing "wait for the timer" message;
  • pistons do not extend or retract;
  • explosions destroy no blocks.

The marker is released when the queue completes, or right away if the queue does not start or starting it throws. In the test runs the plot was free again 6 to 12 ticks after the command.

The decisions are in small helpers on PlotModificationManager so they can be tested without a running server; the listeners call them.

Side effect

/plot clear and /plot set now also lock the plot for the few ticks their queue runs: pistons stop and TNT destroys nothing during that time. Redstone builds can fall out of step for those ticks.

Tests

19 unit tests for the marking, the release after completion and when the queue does not start, and the edit decision with and without the bypass permission.

In game, after the change, on 7.6.1 with WorldEdit and FAWE: no road or wall block came out of the merge window with Efficiency V, with instabreak, with pistons or with TNT. After release, building, pistons and TNT worked normally, and after unlinking the road was protected again.

Not part of this change

  • Not tested in game: TNT that is thrown from another plot into a merging plot.
  • Not locked and not tested: block changes by mobs with entity-change-block = true, falling blocks, liquids and dispensers during the window.
  • Not tested in game: trusted players and members, merging with another owner's plot, auto_merge on claim, and a server stop while the plot is locked.

This replaces my earlier attempt in #4038.

Merging marks the road as part of the plot before the queue has replaced it, so the owner could break road blocks and keep them. The plots are now marked as running until the queue has finished, for /plot merge and for the merge of a multi-plot /plot auto, and block break and place are refused on a plot with a running operation. Explosions destroy no blocks and pistons move no blocks on such a plot either, as both could take road and wall blocks in the same window.
@TheMeinerLP
TheMeinerLP requested a review from a team as a code owner November 26, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

You can break blocks from the road while merging is in progress

1 participant