Lazy copying
> /lazycopy > 92083901 block(s) were not copied. I'll do it later, promise! Basically it will copy it on the fly whenever you decide to do something with it e.g. paste or save it as a schematic.
This commit is contained in:
parent
ae1ce1f1b8
commit
8609741555
@ -24,7 +24,7 @@ public class Settings {
|
|||||||
public static boolean STORE_CLIPBOARD_ON_DISK = false;
|
public static boolean STORE_CLIPBOARD_ON_DISK = false;
|
||||||
|
|
||||||
public static int DELETE_HISTORY_AFTER_DAYS = 7;
|
public static int DELETE_HISTORY_AFTER_DAYS = 7;
|
||||||
public static int DELETE_CLIPBOARD_AFTER_DAYS = 0;
|
public static int DELETE_CLIPBOARD_AFTER_DAYS = 1;
|
||||||
public static int COMPRESSION_LEVEL = 0;
|
public static int COMPRESSION_LEVEL = 0;
|
||||||
public static int BUFFER_SIZE = 531441;
|
public static int BUFFER_SIZE = 531441;
|
||||||
public static boolean METRICS = true;
|
public static boolean METRICS = true;
|
||||||
|
@ -10,6 +10,7 @@ import com.boydti.fawe.util.TaskManager;
|
|||||||
import com.boydti.fawe.util.WEManager;
|
import com.boydti.fawe.util.WEManager;
|
||||||
import com.boydti.fawe.wrappers.PlayerWrapper;
|
import com.boydti.fawe.wrappers.PlayerWrapper;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -113,6 +114,11 @@ public abstract class FawePlayer<T> {
|
|||||||
DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
|
DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
LocalSession session = getSession();
|
LocalSession session = getSession();
|
||||||
|
try {
|
||||||
|
if (session.getClipboard() != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (EmptyClipboardException e) {}
|
||||||
if (player != null && session != null) {
|
if (player != null && session != null) {
|
||||||
sendMessage("&d" + BBC.PREFIX.s() + " " + BBC.LOADING_CLIPBOARD.s());
|
sendMessage("&d" + BBC.PREFIX.s() + " " + BBC.LOADING_CLIPBOARD.s());
|
||||||
WorldData worldData = player.getWorld().getWorldData();
|
WorldData worldData = player.getWorld().getWorldData();
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.boydti.fawe.object.clipboard;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class LazyClipboard extends FaweClipboard {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract BaseBlock getBlock(int x, int y, int z);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract List<? extends Entity> getEntities();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(int x, int y, int z, BaseBlock block) {
|
||||||
|
throw new UnsupportedOperationException("Clipboard is immutable");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entity createEntity(Extent world, double x, double y, double z, float yaw, float pitch, BaseEntity entity) {
|
||||||
|
throw new UnsupportedOperationException("Clipboard is immutable");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(ClipboardEntity clipboardEntity) {
|
||||||
|
throw new UnsupportedOperationException("Clipboard is immutable");
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
|
import com.boydti.fawe.object.clipboard.LazyClipboard;
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
@ -27,6 +28,8 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
@ -46,6 +49,8 @@ import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
|||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||||
@ -68,6 +73,50 @@ public class ClipboardCommands {
|
|||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "/lazycopy" },
|
||||||
|
flags = "em",
|
||||||
|
desc = "Lazily copy the selection to the clipboard",
|
||||||
|
help = "Lazily copy the selection to the clipboard\n" +
|
||||||
|
"Flags:\n" +
|
||||||
|
" -e controls whether entities are copied\n" +
|
||||||
|
" -m sets a source mask so that excluded blocks become air\n" +
|
||||||
|
"WARNING: Pasting entities cannot yet be undone!",
|
||||||
|
max = 0
|
||||||
|
)
|
||||||
|
@CommandPermissions("worldedit.clipboard.lazycopy")
|
||||||
|
public void lazyCopy(Player player, LocalSession session, final EditSession editSession,
|
||||||
|
@Selection final Region region, @Switch('e') boolean copyEntities,
|
||||||
|
@Switch('m') Mask mask) throws WorldEditException {
|
||||||
|
|
||||||
|
Vector origin = region.getMinimumPoint();
|
||||||
|
final int mx = origin.getBlockX();
|
||||||
|
final int my = origin.getBlockY();
|
||||||
|
final int mz = origin.getBlockZ();
|
||||||
|
LazyClipboard lazyClipboard = new LazyClipboard() {
|
||||||
|
@Override
|
||||||
|
public BaseBlock getBlock(int x, int y, int z) {
|
||||||
|
int xx = mx + x;
|
||||||
|
int yy = my + y;
|
||||||
|
int zz = mz + z;
|
||||||
|
return editSession.getLazyBlock(xx, yy, zz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Entity> getEntities() {
|
||||||
|
return editSession.getEntities(region);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||||
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
|
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorld().getWorldData()));
|
||||||
|
player.print(region.getArea() + " block(s) were not copied. I'll do it later, promise!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/copy" },
|
aliases = { "/copy" },
|
||||||
flags = "em",
|
flags = "em",
|
||||||
|
@ -94,7 +94,7 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
this.mz = origin.getBlockZ();
|
this.mz = origin.getBlockZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockArrayClipboard(Region region, DiskOptimizedClipboard clipboard) {
|
public BlockArrayClipboard(Region region, FaweClipboard clipboard) {
|
||||||
checkNotNull(region);
|
checkNotNull(region);
|
||||||
this.region = region.clone();
|
this.region = region.clone();
|
||||||
this.size = getDimensions();
|
this.size = getDimensions();
|
||||||
|
Loading…
Reference in New Issue
Block a user