feat: check merge limits when completing auto-merge

- Closes #3748
This commit is contained in:
dordsor21 2022-11-11 11:37:56 +00:00
parent 28bd993680
commit e888ea95dc
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 9 additions and 1 deletions

View File

@ -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; return true;
} }

View File

@ -124,7 +124,7 @@ public class Merge extends SubCommand {
return false; return false;
} }
final int size = plot.getConnectedPlots().size(); 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 = PlotMergeEvent event =
this.eventDispatcher.callMerge(plot, direction, max, player); this.eventDispatcher.callMerge(plot, direction, max, player);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {