From aca2d2e5103fc18345674cbc8d4a31a2eba4b0d9 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 31 Jan 2021 11:44:22 +0100 Subject: [PATCH] Fixes https://issues.intellectualsites.com/issue/PS-186 --- .../com/plotsquared/core/command/Owner.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Owner.java b/Core/src/main/java/com/plotsquared/core/command/Owner.java index e2782fc6f..0afc6c288 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Owner.java +++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java @@ -33,6 +33,8 @@ import com.plotsquared.core.events.PlotChangeOwnerEvent; import com.plotsquared.core.events.PlotUnlinkEvent; import com.plotsquared.core.events.Result; import com.plotsquared.core.permissions.Permission; +import com.plotsquared.core.player.MetaDataAccess; +import com.plotsquared.core.player.PlayerMetaDataKeys; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.EventDispatcher; @@ -152,9 +154,18 @@ public class Owner extends SetCommand { int currentPlots = (Settings.Limit.GLOBAL ? other.getPlotCount() : other.getPlotCount(plot.getWorldName())) + size; - if (currentPlots > other.getAllowedPlots()) { - player.sendMessage(TranslatableCaption.of("permission.cant_transfer_more_plots")); - return; + try (final MetaDataAccess metaDataAccess = player.accessPersistentMetaData(PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) { + int grants = 0; + if (currentPlots >= other.getAllowedPlots()) { + if (metaDataAccess.isPresent()) { + grants = metaDataAccess.get().orElse(0); + if (grants <= 0) { + metaDataAccess.remove(); + player.sendMessage(TranslatableCaption.of("permission.cant_transfer_more_plots")); + return; + } + } + } } } final UUID finalUUID = uuid;