Should probably limit the size, also...

If you want to select some cavity, just use `//sel fuzzy` and `//pos1`
while standing there
This commit is contained in:
Jesse Boyd 2016-12-12 21:22:47 +11:00
parent 79041d7671
commit 0a3a1c813d
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 40 additions and 18 deletions

View File

@ -19,6 +19,7 @@ import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -113,11 +114,18 @@ public abstract class FawePlayer<T> extends Metadatable {
try {
run.run();
} catch (Throwable e) {
FaweException fe = FaweException.get(e);
if (fe != null) {
sendMessage(fe.getMessage());
while (e.getCause() != null) {
e = e.getCause();
}
if (e instanceof WorldEditException) {
sendMessage(BBC.getPrefix() + e.getLocalizedMessage());
} else {
e.printStackTrace();
FaweException fe = FaweException.get(e);
if (fe != null) {
sendMessage(fe.getMessage());
} else {
e.printStackTrace();
}
}
}
runningCount.decrementAndGet();

View File

@ -24,6 +24,7 @@ public class FuzzyRegion extends AbstractRegion {
private int minX, minY, minZ, maxX, maxY, maxZ;
private int offsetX, offsetY, offsetZ;
private Extent extent;
private int count = 0;
{
minX = minY = minZ = Integer.MAX_VALUE;
@ -56,7 +57,7 @@ public class FuzzyRegion extends AbstractRegion {
@Override
public int getArea() {
return set.length();
return set.cardinality();
}
public void select(int x, int y, int z) {
@ -123,6 +124,9 @@ public class FuzzyRegion extends AbstractRegion {
public void set(int x, int y, int z) throws RegionOperationException{
if (populated) {
if (++count > 1048576) {
throw new RegionOperationException("Selection is too large! (1048576 blocks)");
}
x -= offsetX;
y -= offsetY;
z -= offsetZ;
@ -135,7 +139,7 @@ public class FuzzyRegion extends AbstractRegion {
}
set.set(pair(x, y, z), true);
if (x >= 1024 || x <= -1024 || z >= 1024 || z <= -1024) {
throw new RegionOperationException("Selection is too large!");
throw new RegionOperationException("Selection is too large! (1024 blocks wide)");
}
if (x > maxX) {
maxX = x;

View File

@ -342,10 +342,10 @@ public class PlatformManager {
public void handleBlockInteract(BlockInteractEvent event) {
// Create a proxy actor with a potentially different world for
// making changes to the world
Actor actor = createProxyActor(event.getCause());
final Actor actor = createProxyActor(event.getCause());
try {
final Location location = event.getLocation();
Vector vector = location.toVector();
final Vector vector = location.toVector();
// At this time, only handle interaction from players
if (actor instanceof Player) {
@ -362,11 +362,16 @@ public class PlatformManager {
return;
}
RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
selector.explainPrimarySelection(actor, session, vector);
}
final RegionSelector selector = session.getRegionSelector(player.getWorld());
FawePlayer<?> fp = FawePlayer.wrap(player);
fp.runAction(new Runnable() {
@Override
public void run() {
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
selector.explainPrimarySelection(actor, session, vector);
}
}
}, true, true);
event.setCancelled(true);
return;
@ -407,11 +412,16 @@ public class PlatformManager {
if (!actor.hasPermission("worldedit.selection.pos")) {
return;
}
RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(actor, session, vector);
}
final RegionSelector selector = session.getRegionSelector(player.getWorld());
FawePlayer<?> fp = FawePlayer.wrap(player);
fp.runAction(new Runnable() {
@Override
public void run() {
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(actor, session, vector);
}
}
}, true, true);
event.setCancelled(true);
return;