3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-20 01:40:06 +01:00

fix: upstream missing Region#getBoundingBox() (#1908)

Use block change limit for //copy and //cut

(cherry picked from commit fd8dbdd7b7b8b561db98a45b4eae3810dedb1551)
Dieser Commit ist enthalten in:
Hannes Greule 2022-08-19 13:41:24 +02:00 committet von GitHub
Ursprung cc1b466a04
Commit ab659eadde
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 29 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -38,6 +38,7 @@ import com.google.common.collect.Lists;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
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)
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(
name = "/copy",
aliases = "/cp",

Datei anzeigen

@ -256,6 +256,11 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
return pos1.getMaximum(pos2);
}
@Override
public CuboidRegion getBoundingBox() {
return this;
}
@Override
public int getMinimumY() {
return minY;

Datei anzeigen

@ -72,6 +72,15 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
}
//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.
* Note: Coordinates will not be integers