Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,25 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard {

public final Region region;

/**
* New {@link ReadOnlyClipboard} instance for the given region with max volume of {@link Integer#MAX_VALUE}. Initial offset
* is the clipboard minimum point.
*
* @param region dimensions of this clipboard instance.
*/
public ReadOnlyClipboard(Region region) {
super(region);
this(region, Integer.MAX_VALUE);
}

/**
* New {@link ReadOnlyClipboard} instance for the given region with the given maximum volume.
*
* @param region dimensions of this clipboard instance.
* @param maxSize maximum allowable size of the clipboard. A value of -1 implies infinite volume.
* @since TODO
*/
public ReadOnlyClipboard(Region region, long maxSize) {
super(region, maxSize);
this.region = region.clone();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,57 @@ public abstract class SimpleClipboard implements Clipboard {
private final int volume;
private BlockVector3 origin;

/**
* New {@link SimpleClipboard} instance for the given region with max volume of {@link Integer#MAX_VALUE}. Initial offset
* is the clipboard minimum point.
*
* @param region dimensions of this clipboard instance.
*/
SimpleClipboard(Region region) {
this(region.getDimensions(), region.getMinimumPoint());
}

/**
* New {@link SimpleClipboard} instance with max volume of {@link Integer#MAX_VALUE}.
*
* @param dimensions dimensions of this clipboard instance.
* @param offset initial offset of this clipboard.
*/
SimpleClipboard(BlockVector3 dimensions, BlockVector3 offset) {
this(dimensions, offset, Integer.MAX_VALUE);
}

/**
* New {@link SimpleClipboard} instance for the given region with the given maximum volume.
*
* @param region dimensions of this clipboard instance.
* @param maxSize maximum allowable size of the clipboard implementation. A value of -1 implies infinite volume.
* @since TODO
*/
SimpleClipboard(Region region, long maxSize) {
this(region.getDimensions(), region.getMinimumPoint(), maxSize);
}

/**
* New {@link SimpleClipboard} instance with given maximum volume.
*
* @param dimensions dimensions of this clipboard instance.
* @param offset initial offset of this clipboard.
* @param maxSize maximum allowable size of the clipboard implementation. A value of -1 implies infinite volume.
* @since TODO
*/
SimpleClipboard(BlockVector3 dimensions, BlockVector3 offset, long maxSize) {
this.size = dimensions;
this.offset = offset;
long longVolume = (long) getWidth() * (long) getHeight() * (long) getLength();
if (longVolume >= Integer.MAX_VALUE) {
if (maxSize != -1 && longVolume >= maxSize) {
throw new IllegalArgumentException("Dimensions are too large for this clipboard format.");
}
this.area = getWidth() * getLength();
this.volume = (int) longVolume;
this.origin = BlockVector3.ZERO;
}

SimpleClipboard(Region region) {
this(region.getDimensions(), region.getMinimumPoint());
}

protected void setOffset(final BlockVector3 offset) {
this.offset = offset;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.fastasyncworldedit.core.extent.clipboard;

import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent;
import com.fastasyncworldedit.core.util.ExtentTraverser;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EditSessionBuilder;
import com.sk89q.worldedit.WorldEdit;
Expand Down Expand Up @@ -39,17 +42,19 @@ public WorldCopyClipboard(Supplier<Extent> supplier, Region region) {
*/
@Deprecated(forRemoval = true, since = "2.13.0")
public WorldCopyClipboard(Supplier<Extent> supplier, Region region, boolean hasEntities, boolean hasBiomes) {
super(region);
this.hasBiomes = hasBiomes;
this.hasEntities = hasEntities;
this.extent = supplier.get();
this(supplier.get(), region, hasEntities, hasBiomes);
}

private WorldCopyClipboard(Extent extent, Region region, boolean hasEntities, boolean hasBiomes) {
super(region);
super(region, -1);
this.hasBiomes = hasBiomes;
this.hasEntities = hasEntities;
this.extent = extent;
if (new ExtentTraverser<>(extent).find(SingleThreadQueueExtent.class) != null) {
// If we have a SingleThreadQueueExtent present, uncache so it cannot be used again for pasting (and therefore
// potentially resetting the world)
Fawe.instance().getQueueHandler().unCache();
}
}

public static WorldCopyClipboard of(Extent extent, Region region) {
Expand Down
Loading