From eb11d9e3aadcd5ee5017e0ad9e519aec902ebcfc Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 28 Jun 2021 16:40:01 +0200 Subject: [PATCH] Handle add & trust permission ranges properly --- Core/src/main/java/com/plotsquared/core/command/Add.java | 5 +++-- Core/src/main/java/com/plotsquared/core/command/Trust.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Add.java b/Core/src/main/java/com/plotsquared/core/command/Add.java index 4cb2953c4..dc7f9ba38 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Add.java +++ b/Core/src/main/java/com/plotsquared/core/command/Add.java @@ -130,11 +130,12 @@ public class Add extends Command { size += plot.getTrusted().contains(uuid) ? 0 : 1; } checkTrue(!uuids.isEmpty(), null); + int localAddSize = plot.getMembers().size(); int maxAddSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_ADD, Settings.Limit.MAX_PLOTS); - if (size > maxAddSize) { + if (localAddSize > maxAddSize) { player.sendMessage( TranslatableCaption.of("members.plot_max_members_added"), - Template.of("amount", String.valueOf(size - 1)) + Template.of("amount", String.valueOf(localAddSize)) ); return; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Trust.java b/Core/src/main/java/com/plotsquared/core/command/Trust.java index c8685d110..4f209a8b1 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trust.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trust.java @@ -136,11 +136,12 @@ public class Trust extends Command { size += currentPlot.getMembers().contains(uuid) ? 0 : 1; } checkTrue(!uuids.isEmpty(), null); + int localTrustSize = currentPlot.getTrusted().size(); int maxTrustSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_TRUST, Settings.Limit.MAX_PLOTS); - if (size > maxTrustSize) { + if (localTrustSize > maxTrustSize) { player.sendMessage( TranslatableCaption.of("members.plot_max_members_trusted"), - Template.of("amount", String.valueOf(size - 1)) + Template.of("amount", String.valueOf(localTrustSize)) ); return; }