diff --git a/src/main/java/me/youhavetrouble/blockedit/BlockEditCommands.java b/src/main/java/me/youhavetrouble/blockedit/BlockEditCommands.java index 9f08b40..e9a0519 100644 --- a/src/main/java/me/youhavetrouble/blockedit/BlockEditCommands.java +++ b/src/main/java/me/youhavetrouble/blockedit/BlockEditCommands.java @@ -216,6 +216,29 @@ public class BlockEditCommands { return Command.SINGLE_SUCCESS; }) + .then( + Commands.argument("chunks_per_tick", IntegerArgumentType.integer(1)) + .executes(ctx -> { + Player player = (Player) ctx.getSource().getSender(); + BEPlayer bePlayer = BEPlayer.getByPlayer(player); + Vector playerLocationVector = player.getLocation().toBlockLocation().toVector(); + + HashMap absoluteBlocks = new HashMap<>(bePlayer.getClipboard().getBlocks().size()); + + int chunksPerTick = ctx.getArgument("chunks_per_tick", Integer.class); + + bePlayer.getClipboard().getBlocks().forEach((vector, blockState) -> { + Vector absolutePosition = vector.clone().add(playerLocationVector); + absoluteBlocks.put(absolutePosition, blockState); + }); + + Selection selection = Selection.fromClipboard(absoluteBlocks.keySet(), player.getWorld()); + BlockEditAPI.runOperation(selection, chunksPerTick, new PasteOperation(absoluteBlocks)); + player.sendMessage(Component.text(BELocale.getLocale(player.locale()).pastingClipboard, NamedTextColor.GRAY)); + + return Command.SINGLE_SUCCESS; + }) + ) .build(); }