mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 21:56:33 +01:00
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:
parent
79041d7671
commit
0a3a1c813d
@ -19,6 +19,7 @@ import com.sk89q.worldedit.IncompleteRegionException;
|
|||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
@ -113,11 +114,18 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
try {
|
try {
|
||||||
run.run();
|
run.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
FaweException fe = FaweException.get(e);
|
while (e.getCause() != null) {
|
||||||
if (fe != null) {
|
e = e.getCause();
|
||||||
sendMessage(fe.getMessage());
|
}
|
||||||
|
if (e instanceof WorldEditException) {
|
||||||
|
sendMessage(BBC.getPrefix() + e.getLocalizedMessage());
|
||||||
} else {
|
} else {
|
||||||
e.printStackTrace();
|
FaweException fe = FaweException.get(e);
|
||||||
|
if (fe != null) {
|
||||||
|
sendMessage(fe.getMessage());
|
||||||
|
} else {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runningCount.decrementAndGet();
|
runningCount.decrementAndGet();
|
||||||
|
@ -24,6 +24,7 @@ public class FuzzyRegion extends AbstractRegion {
|
|||||||
private int minX, minY, minZ, maxX, maxY, maxZ;
|
private int minX, minY, minZ, maxX, maxY, maxZ;
|
||||||
private int offsetX, offsetY, offsetZ;
|
private int offsetX, offsetY, offsetZ;
|
||||||
private Extent extent;
|
private Extent extent;
|
||||||
|
private int count = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
minX = minY = minZ = Integer.MAX_VALUE;
|
minX = minY = minZ = Integer.MAX_VALUE;
|
||||||
@ -56,7 +57,7 @@ public class FuzzyRegion extends AbstractRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public int getArea() {
|
||||||
return set.length();
|
return set.cardinality();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void select(int x, int y, int z) {
|
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{
|
public void set(int x, int y, int z) throws RegionOperationException{
|
||||||
if (populated) {
|
if (populated) {
|
||||||
|
if (++count > 1048576) {
|
||||||
|
throw new RegionOperationException("Selection is too large! (1048576 blocks)");
|
||||||
|
}
|
||||||
x -= offsetX;
|
x -= offsetX;
|
||||||
y -= offsetY;
|
y -= offsetY;
|
||||||
z -= offsetZ;
|
z -= offsetZ;
|
||||||
@ -135,7 +139,7 @@ public class FuzzyRegion extends AbstractRegion {
|
|||||||
}
|
}
|
||||||
set.set(pair(x, y, z), true);
|
set.set(pair(x, y, z), true);
|
||||||
if (x >= 1024 || x <= -1024 || z >= 1024 || z <= -1024) {
|
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) {
|
if (x > maxX) {
|
||||||
maxX = x;
|
maxX = x;
|
||||||
|
@ -342,10 +342,10 @@ public class PlatformManager {
|
|||||||
public void handleBlockInteract(BlockInteractEvent event) {
|
public void handleBlockInteract(BlockInteractEvent event) {
|
||||||
// Create a proxy actor with a potentially different world for
|
// Create a proxy actor with a potentially different world for
|
||||||
// making changes to the world
|
// making changes to the world
|
||||||
Actor actor = createProxyActor(event.getCause());
|
final Actor actor = createProxyActor(event.getCause());
|
||||||
try {
|
try {
|
||||||
final Location location = event.getLocation();
|
final Location location = event.getLocation();
|
||||||
Vector vector = location.toVector();
|
final Vector vector = location.toVector();
|
||||||
|
|
||||||
// At this time, only handle interaction from players
|
// At this time, only handle interaction from players
|
||||||
if (actor instanceof Player) {
|
if (actor instanceof Player) {
|
||||||
@ -362,11 +362,16 @@ public class PlatformManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
final RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
|
FawePlayer<?> fp = FawePlayer.wrap(player);
|
||||||
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
|
fp.runAction(new Runnable() {
|
||||||
selector.explainPrimarySelection(actor, session, vector);
|
@Override
|
||||||
}
|
public void run() {
|
||||||
|
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
|
||||||
|
selector.explainPrimarySelection(actor, session, vector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true, true);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -407,11 +412,16 @@ public class PlatformManager {
|
|||||||
if (!actor.hasPermission("worldedit.selection.pos")) {
|
if (!actor.hasPermission("worldedit.selection.pos")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
FawePlayer<?> fp = FawePlayer.wrap(player);
|
||||||
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
|
fp.runAction(new Runnable() {
|
||||||
selector.explainSecondarySelection(actor, session, vector);
|
@Override
|
||||||
}
|
public void run() {
|
||||||
|
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
|
||||||
|
selector.explainSecondarySelection(actor, session, vector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true, true);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user