Refactor: add javadoc to Clipboard#create and improve variables when delegating to another paste method

This commit is contained in:
dordsor21 2021-12-30 16:04:38 +00:00
parent 9faacb38ef
commit f30ea96268
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -70,6 +70,10 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
//FAWE end //FAWE end
//FAWE start //FAWE start
/**
* Creates a new {@link ReadOnlyClipboard}.
*/
static Clipboard create(Region region) { static Clipboard create(Region region) {
checkNotNull(region); checkNotNull(region);
checkNotNull( checkNotNull(
@ -85,6 +89,13 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
return ReadOnlyClipboard.of(session, region); return ReadOnlyClipboard.of(session, region);
} }
/**
* Create a new {@link com.fastasyncworldedit.core.extent.clipboard.SimpleClipboard} instance.
* Will be one of the following, depending on settings:
* - {@link DiskOptimizedClipboard}
* - {@link CPUOptimizedClipboard}
* - {@link MemoryOptimizedClipboard}
*/
static Clipboard create(Region region, UUID uuid) { static Clipboard create(Region region, UUID uuid) {
if (Settings.settings().CLIPBOARD.USE_DISK) { if (Settings.settings().CLIPBOARD.USE_DISK) {
return new DiskOptimizedClipboard(region, uuid); return new DiskOptimizedClipboard(region, uuid);
@ -249,7 +260,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
*/ */
default EditSession paste( default EditSession paste(
World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
boolean copyEntities, @Nullable Transform transform boolean pasteEntities, @Nullable Transform transform
) { ) {
checkNotNull(world); checkNotNull(world);
checkNotNull(to); checkNotNull(to);
@ -275,7 +286,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
if (transform != null && !transform.isIdentity()) { if (transform != null && !transform.isIdentity()) {
extent = new BlockTransformExtent(this, transform); extent = new BlockTransformExtent(this, transform);
} else if (sourceMask == null) { } else if (sourceMask == null) {
paste(editSession, to, pasteAir); paste(editSession, to, pasteAir, pasteEntities, hasBiomes());
editSession.flushQueue(); editSession.flushQueue();
return editSession; return editSession;
} }
@ -285,7 +296,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
if (transform != null && !transform.isIdentity()) { if (transform != null && !transform.isIdentity()) {
copy.setTransform(transform); copy.setTransform(transform);
} }
copy.setCopyingEntities(copyEntities); copy.setCopyingEntities(pasteEntities);
if (sourceMask != null) { if (sourceMask != null) {
new MaskTraverser(sourceMask).reset(extent); new MaskTraverser(sourceMask).reset(extent);
copy.setSourceMask(sourceMask); copy.setSourceMask(sourceMask);