3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 11:00:04 +01:00

Fix confirmation

Dieser Commit ist enthalten in:
Jesse Boyd 2019-11-24 04:08:17 +00:00
Ursprung 913ada31fb
Commit 00e0ac721f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F

Datei anzeigen

@ -42,10 +42,11 @@ public @interface Confirm {
@Override @Override
public boolean passes(Actor actor, InjectedValueAccess context, double value) { public boolean passes(Actor actor, InjectedValueAccess context, double value) {
Region region = context.injectedValue(Key.of(Region.class, Selection.class)).orElseThrow(IncompleteRegionException::new); Region region = context.injectedValue(Key.of(Region.class, Selection.class)).orElseThrow(IncompleteRegionException::new);
BlockVector3 min = region.getMinimumPoint(); BlockVector3 pos1 = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 pos2 = region.getMaximumPoint();
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1) * (int) value; long area = (pos2.getX() - pos1.getX()) * (pos2.getZ() - pos1.getZ() + 1) * (long) value;
if (area > 2 << 18) { long max = 2 << 18; // TODO configurable?
if (max != -1 && area > max) {
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , min, max, getArgs(context))); actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , min, max, getArgs(context)));
return confirm(actor, context); return confirm(actor, context);
} }
@ -56,7 +57,7 @@ public @interface Confirm {
@Override @Override
public boolean passes(Actor actor, InjectedValueAccess context, double value) { public boolean passes(Actor actor, InjectedValueAccess context, double value) {
int max = WorldEdit.getInstance().getConfiguration().maxRadius; int max = WorldEdit.getInstance().getConfiguration().maxRadius;
if (value > max) { if (max != -1 && value > max) {
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context))); actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context)));
return Processor.confirm(actor, context); return Processor.confirm(actor, context);
} }
@ -67,7 +68,7 @@ public @interface Confirm {
@Override @Override
public boolean passes(Actor actor, InjectedValueAccess context, double value) { public boolean passes(Actor actor, InjectedValueAccess context, double value) {
int max = 50;// TODO configurable, get Key.of(Method.class) @Limit int max = 50;// TODO configurable, get Key.of(Method.class) @Limit
if (value > max) { if (max != -1 && value > max) {
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context))); actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context)));
return Processor.confirm(actor, context); return Processor.confirm(actor, context);
} }