Fix confirm deadlock and confirm permissions/limits (#718)

Dieser Commit ist enthalten in:
Hannes Greule 2020-10-22 07:28:07 +02:00 committet von GitHub
Ursprung 097f3ec473
Commit 30863c36e7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -192,7 +192,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
if (confirm == null) {
return false;
}
queueAction(confirm::signal);
confirm.signal();
return true;
}

Datei anzeigen

@ -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());
}

Datei anzeigen

@ -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",