From d4687de4590783963ca90998a0faf98147cde648 Mon Sep 17 00:00:00 2001 From: Florian Reuth Date: Sat, 28 Feb 2026 17:37:33 +0100 Subject: [PATCH 1/2] Re-evaluate current plot after unlinking multiple plots Fixes /plot delete deleting the wrong plot when unlinking plots and not moving. Signed-off-by: Florian Reuth --- .../core/plot/PlotModificationManager.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java index cc2f1f0709..d54e1a407d 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java @@ -35,6 +35,8 @@ import com.plotsquared.core.inject.factory.ProgressSubscriberFactory; import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Location; +import com.plotsquared.core.player.MetaDataAccess; +import com.plotsquared.core.player.PlayerMetaDataKeys; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.queue.QueueCoordinator; @@ -380,6 +382,23 @@ public boolean unlinkPlot(final boolean createRoad, final boolean createSign, fi boolean[] merged = new boolean[]{false, false, false, false}; current.setMerged(merged); } + // Update TEMPORARY_LAST_PLOT metadata for all players that were in the merged plot + // so that getCurrentPlot() returns the correct individual plot based on their location + for (final PlotPlayer player : PlotSquared.platform().playerManager().getPlayers()) { + try (final MetaDataAccess lastPlotAccess = + player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) { + final Plot lastPlot = lastPlotAccess.get().orElse(null); + if (lastPlot != null && plots.contains(lastPlot)) { + // Player was in the merged plot, update to their actual current plot + final Plot actualPlot = player.getLocation().getPlot(); + if (actualPlot != null) { + lastPlotAccess.set(actualPlot); + } else { + lastPlotAccess.remove(); + } + } + } + } if (createSign) { queue.setCompleteTask(() -> TaskManager.runTaskAsync(() -> { List> tasks = plots.stream().map(current -> PlotSquared.platform().playerManager() From fbcbee326e097cca2508990346b453aff0cb6f4b Mon Sep 17 00:00:00 2001 From: Florian Reuth Date: Fri, 10 Apr 2026 15:10:31 +0200 Subject: [PATCH 2/2] No final Signed-off-by: Florian Reuth --- .../plotsquared/core/plot/PlotModificationManager.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java index d54e1a407d..d38625b007 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java @@ -384,13 +384,12 @@ public boolean unlinkPlot(final boolean createRoad, final boolean createSign, fi } // Update TEMPORARY_LAST_PLOT metadata for all players that were in the merged plot // so that getCurrentPlot() returns the correct individual plot based on their location - for (final PlotPlayer player : PlotSquared.platform().playerManager().getPlayers()) { - try (final MetaDataAccess lastPlotAccess = - player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) { - final Plot lastPlot = lastPlotAccess.get().orElse(null); + for (PlotPlayer player : PlotSquared.platform().playerManager().getPlayers()) { + try (MetaDataAccess lastPlotAccess = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) { + Plot lastPlot = lastPlotAccess.get().orElse(null); if (lastPlot != null && plots.contains(lastPlot)) { // Player was in the merged plot, update to their actual current plot - final Plot actualPlot = player.getLocation().getPlot(); + Plot actualPlot = player.getLocation().getPlot(); if (actualPlot != null) { lastPlotAccess.set(actualPlot); } else {