feat: add a permission to override-allow a merge if the other plot's owner is offline

- Closes #3779
This commit is contained in:
dordsor21 2022-10-09 16:34:04 +01:00
parent 3effaefda7
commit 5d29c03a35
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 23 additions and 1 deletions

View File

@ -282,7 +282,28 @@ public class Merge extends SubCommand {
run.run(); 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")); player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
return false; return false;
} }

View File

@ -162,6 +162,7 @@ public enum Permission {
PERMISSION_LIST_AREA("plots.list.area"), PERMISSION_LIST_AREA("plots.list.area"),
PERMISSION_ADMIN_COMMAND_LOAD("plots.admin.command.load"), PERMISSION_ADMIN_COMMAND_LOAD("plots.admin.command.load"),
PERMISSION_ADMIN_COMMAND_MERGE("plots.admin.command.merge"), 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_ADMIN_COMMAND_SET_OWNER("plots.admin.command.setowner"),
PERMISSION_COMMENT("plots.comment"), PERMISSION_COMMENT("plots.comment"),
PERMISSION_INBOX("plots.inbox"), PERMISSION_INBOX("plots.inbox"),