From e888ea95dc75c47daed0a10ed8d9c9de9a1519d3 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 11 Nov 2022 11:37:56 +0000 Subject: [PATCH] feat: check merge limits when completing auto-merge - Closes #3748 --- Core/src/main/java/com/plotsquared/core/command/Auto.java | 8 ++++++++ .../src/main/java/com/plotsquared/core/command/Merge.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java index 60ed4bfea..8c428c56e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -142,6 +142,14 @@ public class Auto extends SubCommand { } } } + int maxMerge = Permissions.hasPermissionRange(player, Permission.PERMISSION_MERGE, Settings.Limit.MAX_PLOTS); + if (sizeX * sizeZ > maxMerge) { + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", Permission.PERMISSION_MERGE + "." + (sizeX * sizeZ)) + ); + return false; + } return true; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Merge.java b/Core/src/main/java/com/plotsquared/core/command/Merge.java index 8c9976197..d548e95a3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -124,7 +124,7 @@ public class Merge extends SubCommand { return false; } final int size = plot.getConnectedPlots().size(); - int max = Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS); + int max = Permissions.hasPermissionRange(player, Permission.PERMISSION_MERGE, Settings.Limit.MAX_PLOTS); PlotMergeEvent event = this.eventDispatcher.callMerge(plot, direction, max, player); if (event.getEventResult() == Result.DENY) {