Skip to content
Permalink
Browse files

Added flags to copy biomes and entities.

  • Loading branch information...
me4502 committed Jun 13, 2019
1 parent 9af897b commit 3c90038910ad0de1915f7327e4f68ca6c3d408d8
@@ -42,7 +42,7 @@ public AreaCommands(CraftBookPlugin plugin) {

private CraftBookPlugin plugin = CraftBookPlugin.inst();

@Command(aliases = {"save"}, desc = "Saves the selected area", usage = "[-n namespace ] <id>", flags = "n:", min = 1)
@Command(aliases = {"save"}, desc = "Saves the selected area", usage = "[-n namespace ] <id> [-e] [-b]", flags = "ebn:", min = 1)
public void saveArea(CommandContext context, CommandSender sender) throws CommandException {

if (!(sender instanceof Player)) return;
@@ -52,6 +52,9 @@ public void saveArea(CommandContext context, CommandSender sender) throws Comman
String namespace = player.getCraftBookId();
boolean personal = true;

boolean copyEntities = context.hasFlag('e');
boolean copyBiomes = context.hasFlag('b');

if (context.hasFlag('n')) {
if (!player.hasPermission("craftbook.mech.area.save." + context.getFlag('n')))
throw new CommandException("You do not have permission to use this namespace.");
@@ -105,7 +108,7 @@ public void saveArea(CommandContext context, CommandSender sender) throws Comman
}

// Copy
BlockArrayClipboard copy = CopyManager.getInstance().copy(sel);
BlockArrayClipboard copy = CopyManager.getInstance().copy(sel, copyEntities, copyBiomes);

plugin.getServer().getLogger().info(player.getName() + " saving toggle area with folder '" + namespace +
"' and ID '" + id + "'.");
@@ -220,13 +220,25 @@ public void save(String namespace, String id, BlockArrayClipboard clipboard) thr
* @throws WorldEditException If something went wrong.
*/
public BlockArrayClipboard copy(Region region) throws WorldEditException {
return copy(region, false, false);
}

/**
* Copies a region into the BlockArrayClipboard.
*
* @param region The region
* @return The BlockArrayClipboard
* @throws WorldEditException If something went wrong.
*/
public BlockArrayClipboard copy(Region region, boolean copyEntities, boolean copyBiomes) throws WorldEditException {
BlockArrayClipboard copy = new BlockArrayClipboard(region);
// copy.setOrigin(origin);

EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(region.getWorld(), -1);

ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, region, copy, region.getMinimumPoint());
forwardExtentCopy.setCopyingEntities(true);
forwardExtentCopy.setCopyingEntities(copyEntities);
forwardExtentCopy.setCopyingBiomes(copyBiomes);
Operations.complete(forwardExtentCopy);

return copy;
@@ -244,6 +256,8 @@ public void paste(BlockArrayClipboard clipboard) throws WorldEditException {
Operation operation = new ClipboardHolder(clipboard)
.createPaste(editSession)
.to(clipboard.getOrigin())
.copyBiomes(true)
.copyEntities(true)
.ignoreAirBlocks(false)
.build();

0 comments on commit 3c90038

Please sign in to comment.
You can’t perform that action at this time.