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 @@ -17,14 +17,24 @@ public abstract class SimpleClipboard implements Clipboard {
this.size = dimensions;
this.offset = offset;
long longVolume = (long) getWidth() * (long) getHeight() * (long) getLength();
if (longVolume >= Integer.MAX_VALUE) {
long maxSize = getMaxSize();
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;
}

/**
* Get the maximum size allowed by this clipboard implementation
*
* @return maximum size in blocks of this clipboard implementation.
*/
public long getMaxSize() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An instance method is somehow the wrong approach, mainly because it requires an escaping this in the constructor, and it also doesn't have any different use really. Maybe SimpleClipboard is generally a rather problematic abstraction?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but altering the hierarchy is rather a v3 change and it would be nice to have this working a little sooner than that... We could always deprecate for removal upon implementation and put the change into V3 immediately.

Alternatively I suppose we could just reimplement in a different class entirely? Certainly the clipboard hierarchy could do with some cleanup at some point regardless

return Integer.MAX_VALUE;
}

SimpleClipboard(Region region) {
this(region.getDimensions(), region.getMinimumPoint());
}
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);
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 All @@ -64,6 +69,11 @@ public static WorldCopyClipboard of(Extent extent, Region region, boolean hasEnt
return new WorldCopyClipboard(extent, region, hasEntities, hasBiomes);
}

@Override
public long getMaxSize() {
return -1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use Long.MAX_VALUE? The specification of the method in the superclass should also cover which values are valid.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to convey actually unlimited rather than functionally unlimited. It should go into the javadoc though yeah

}

public Extent getExtent() {
return extent;
}
Expand Down
Loading