mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-01-30 04:02:03 +01:00
Improved edit confirmation
This commit is contained in:
parent
7065492740
commit
668f6c6e34
@ -256,7 +256,7 @@ public enum BBC {
|
||||
WORLDEDIT_SOME_FAILS_BLOCKBAG("&cMissing blocks: %s0", "Error"),
|
||||
|
||||
WORLDEDIT_CANCEL_COUNT("&cCancelled %s0 edits.", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_CONFIRM("&7Your selection is large (%s0 -> %s1). Use &c//confirm &7to execute &c%s2", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_CONFIRM("&7Your selection is large (&c%s0 &7-> &c%s1&7, containing &c%s3&7 blocks). Use &c//confirm &7to execute &c%s2", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON("&cYour WorldEdit action was cancelled:&7 %s0&c.", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_MANUAL("Manual cancellation", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_LOW_MEMORY("Low memory", "Cancel"),
|
||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.world.registry.WorldData;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
@ -128,7 +129,8 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
}
|
||||
if (times > limit) {
|
||||
setMeta("cmdConfirm", command);
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command));
|
||||
String volume = "<unspecified>";
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command, volume));
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +141,8 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
if (radius > 0) {
|
||||
if (radius > 448) {
|
||||
setMeta("cmdConfirm", command);
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command));
|
||||
long volume = (long) (Math.PI * ((double) radius * radius));
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command, NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -149,12 +152,13 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
return;
|
||||
}
|
||||
if (region != null) {
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
Vector min = region.getMinimumPoint().toBlockVector();
|
||||
Vector max = region.getMaximumPoint().toBlockVector();
|
||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
||||
if (area > 2 << 18) {
|
||||
setMeta("cmdConfirm", command);
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command));
|
||||
long volume = (long) max.subtract(min).add(Vector.ONE).volume() * times;
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -164,12 +168,13 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
return;
|
||||
}
|
||||
if (region != null) {
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
Vector min = region.getMinimumPoint().toBlockVector();
|
||||
Vector max = region.getMaximumPoint().toBlockVector();
|
||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
|
||||
if (area > 2 << 18) {
|
||||
setMeta("cmdConfirm", command);
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command));
|
||||
long volume = (long) max.subtract(min).add(Vector.ONE).volume();
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.command.AnvilCommands;
|
||||
import com.boydti.fawe.command.CFICommands;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||
@ -119,13 +120,14 @@ public final class DocumentationPrinter {
|
||||
writePermissionsWikiTable(stream, builder, "", MaskCommands.class, "/Masks");
|
||||
writePermissionsWikiTable(stream, builder, "", PatternCommands.class, "/Patterns");
|
||||
writePermissionsWikiTable(stream, builder, "", TransformCommands.class, "/Transforms");
|
||||
writePermissionsWikiTable(stream, builder, "/cfi ", CFICommands.class, "Create From Image");
|
||||
stream.println();
|
||||
stream.print("#### Uncategorized\n");
|
||||
stream.append("| Aliases | Permission | flags | Usage |\n");
|
||||
stream.append("| --- | --- | --- | --- |\n");
|
||||
stream.append("| //cancel | fawe.cancel | | Cancels your current operations |\n");
|
||||
stream.append("| /plot replaceall | plots.replaceall | | Replace all blocks in the plot world |\n");
|
||||
stream.append("| /plot createfromimage | plots.createfromimage | | Starts world creation from a heightmap image: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/CreateFromImage) |\n");
|
||||
// stream.append("| /plot createfromimage | plots.createfromimage | | Starts world creation from a heightmap image: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/CreateFromImage) |\n");
|
||||
stream.print("\n---\n");
|
||||
|
||||
stream.print(builder);
|
||||
|
@ -113,4 +113,8 @@ public class BlockVector extends Vector {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + getBlockX() + ", " + getBlockY() + ", " + getBlockZ() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -530,6 +530,10 @@ public class Vector implements Comparable<Vector>, Serializable {
|
||||
return getX() * getX() + getY() * getY() + getZ() * getZ();
|
||||
}
|
||||
|
||||
public double volume() {
|
||||
return getX() * getY() * getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between this vector and another vector.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user