From 30863c36e795ff8372a8ff214bd129f2aa6f6b0c Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Thu, 22 Oct 2020 07:28:07 +0200 Subject: [PATCH] Fix confirm deadlock and confirm permissions/limits (#718) --- .../worldedit/command/util/annotation/Confirm.java | 13 ++++++++----- .../sk89q/worldedit/extension/platform/Actor.java | 2 +- .../worldedit/internal/command/ConfirmHandler.java | 5 +++++ worldedit-core/src/main/resources/lang/strings.json | 2 ++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java index 7d5c26fb7..290dca4b6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java @@ -52,7 +52,8 @@ public @interface Confirm { * (long) value; long max = 2 << 18; if (max != -1 && area > max) { - actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region", pos1, pos2, getArgs(context))); + actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region", + pos1, pos2, getArgs(context), region.getHeight() * area)); return confirm(actor, context); } return true; @@ -63,8 +64,9 @@ public @interface Confirm { public boolean passes(Actor actor, InjectedValueAccess context, double value) { int max = WorldEdit.getInstance().getConfiguration().maxRadius; if (max != -1 && value > max) { - actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region", value, max, getArgs(context))); - return Processor.confirm(actor, context); + actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.radius", + value, max, getArgs(context))); + return confirm(actor, context); } return true; } @@ -74,8 +76,9 @@ public @interface Confirm { public boolean passes(Actor actor, InjectedValueAccess context, double value) { int max = 50; //TODO configurable, get Key.of(Method.class) @Limit if (max != -1 && value > max) { - actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region", value, max, getArgs(context))); - return Processor.confirm(actor, context); + actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.limit", + value, max, getArgs(context))); + return confirm(actor, context); } return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index 5a222f0cf..4ead8d92d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -192,7 +192,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab if (confirm == null) { return false; } - queueAction(confirm::signal); + confirm.signal(); return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/ConfirmHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/ConfirmHandler.java index 05ae8671f..9af58efea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/ConfirmHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/ConfirmHandler.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.internal.command; +import com.boydti.fawe.config.Settings; import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.formatting.text.TextComponent; @@ -46,6 +47,10 @@ public class ConfirmHandler implements CommandCallListener { return; } Actor actor = actorOpt.get(); + // don't check confirmation if actor doesn't need to confirm + if (!Settings.IMP.getLimit(actor).CONFIRM_LARGE) { + return; + } if (!confirmAnnotation.value().passes(actor, parameters, 1)) { throw new StopExecutionException(TextComponent.empty()); } diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 45996376b..5e9d7f986 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -108,6 +108,8 @@ "fawe.cancel.worldedit.cancel.count": "Cancelled {0} edits.", "fawe.cancel.worldedit.cancel.reason.confirm": "Use //confirm to execute {2}", "fawe.cancel.worldedit.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}", + "fawe.cancel.worldedit.cancel.reason.confirm.radius": "Your radius is large ({0} > {1}). Use //confirm to execute {2}", + "fawe.cancel.worldedit.cancel.reason.confirm.limit": "You're exceeding your limit for this action ({0} > {1}). Use //confirm to execute {2}", "fawe.cancel.worldedit.cancel.reason": "Your WorldEdit action was cancelled: {0}.", "fawe.cancel.worldedit.cancel.reason.manual": "Manual cancellation", "fawe.cancel.worldedit.cancel.reason.low.memory": "Low memory",