From 90ebd5d5ed1db0cb5d509b230bc64075df82642c Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 25 Nov 2022 10:48:33 +0000 Subject: [PATCH] feat: add a permission to override-allow a merge if the other plot's owner is offline (#3844) --- .../com/plotsquared/core/command/Merge.java | 23 ++++++++++++++++++- .../core/permissions/Permission.java | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) 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..6da21063b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -282,7 +282,28 @@ public class Merge extends SubCommand { run.run(); } } - if (!force && !isOnline) { + if (force || !isOnline) { + if (force || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_MERGE_OTHER_OFFLINE)) { + if (plot.getPlotModificationManager().autoMerge(direction, maxSize - size, uuids.iterator().next(), player, terrain)) { + if (this.econHandler.isEnabled(plotArea) && price > 0d) { + if (!force && this.econHandler.getMoney(player) < price) { + player.sendMessage( + TranslatableCaption.of("economy.cannot_afford_merge"), + Template.of("money", this.econHandler.format(price)) + ); + return false; + } + this.econHandler.withdrawMoney(player, price); + player.sendMessage( + TranslatableCaption.of("economy.removed_balance"), + Template.of("money", this.econHandler.format(price)) + ); + } + player.sendMessage(TranslatableCaption.of("merge.success_merge")); + eventDispatcher.callPostMerge(player, plot); + return true; + } + } player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/permissions/Permission.java b/Core/src/main/java/com/plotsquared/core/permissions/Permission.java index ffd8f3d5a..8899f233d 100644 --- a/Core/src/main/java/com/plotsquared/core/permissions/Permission.java +++ b/Core/src/main/java/com/plotsquared/core/permissions/Permission.java @@ -162,6 +162,7 @@ public enum Permission { PERMISSION_LIST_AREA("plots.list.area"), PERMISSION_ADMIN_COMMAND_LOAD("plots.admin.command.load"), PERMISSION_ADMIN_COMMAND_MERGE("plots.admin.command.merge"), + PERMISSION_ADMIN_COMMAND_MERGE_OTHER_OFFLINE("plots.admin.command.merge.other.offline"), PERMISSION_ADMIN_COMMAND_SET_OWNER("plots.admin.command.setowner"), PERMISSION_COMMENT("plots.comment"), PERMISSION_INBOX("plots.inbox"),