mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
fix: upstream missing Region#getBoundingBox()
(#1908)
Use block change limit for //copy and //cut (cherry picked from commit fd8dbdd7b7b8b561db98a45b4eae3810dedb1551)
This commit is contained in:
parent
cc1b466a04
commit
ab659eadde
@ -38,6 +38,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||||
@ -105,6 +106,20 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
|||||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
public class ClipboardCommands {
|
public class ClipboardCommands {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws if the region would allocate a clipboard larger than the block change limit.
|
||||||
|
*
|
||||||
|
* @param region The region to check
|
||||||
|
* @param session The session
|
||||||
|
* @throws MaxChangedBlocksException if the volume exceeds the limit
|
||||||
|
*/
|
||||||
|
private void checkRegionBounds(Region region, LocalSession session) throws MaxChangedBlocksException {
|
||||||
|
int limit = session.getBlockChangeLimit();
|
||||||
|
if (region.getBoundingBox().getVolume() > limit) {
|
||||||
|
throw new MaxChangedBlocksException(limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/copy",
|
name = "/copy",
|
||||||
aliases = "/cp",
|
aliases = "/cp",
|
||||||
|
@ -256,6 +256,11 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return pos1.getMaximum(pos2);
|
return pos1.getMaximum(pos2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CuboidRegion getBoundingBox() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinimumY() {
|
public int getMinimumY() {
|
||||||
return minY;
|
return minY;
|
||||||
|
@ -72,6 +72,15 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the bounding box of this region as a {@link CuboidRegion}.
|
||||||
|
*
|
||||||
|
* @return the bounding box
|
||||||
|
*/
|
||||||
|
default CuboidRegion getBoundingBox() {
|
||||||
|
return new CuboidRegion(getMinimumPoint(), getMaximumPoint());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the center point of a region.
|
* Get the center point of a region.
|
||||||
* Note: Coordinates will not be integers
|
* Note: Coordinates will not be integers
|
||||||
|
Loading…
Reference in New Issue
Block a user