From 25ce7a83f134921c1fc2c69f5d92ecb23edf1761 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 13 Nov 2022 10:57:41 +0000 Subject: [PATCH] feat: check merge limits when completing auto-merge (#3868) - 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) {