From fd4b167ac7a5b2da1b2e0b564157693b24578208 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 18 Feb 2011 21:24:12 -0800 Subject: [PATCH] Added -c flag to //distr to print to console. --- .../worldedit/commands/SelectionCommands.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/com/sk89q/worldedit/commands/SelectionCommands.java b/src/com/sk89q/worldedit/commands/SelectionCommands.java index 25ae35826..0367a6590 100644 --- a/src/com/sk89q/worldedit/commands/SelectionCommands.java +++ b/src/com/sk89q/worldedit/commands/SelectionCommands.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.commands; import java.util.List; import java.util.Set; +import java.util.logging.Logger; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; @@ -380,6 +381,7 @@ public class SelectionCommands { aliases = {"/distr"}, usage = "", desc = "Get the distribution of blocks in the selection", + flags = "c", min = 0, max = 0 ) @@ -391,16 +393,28 @@ public class SelectionCommands { List> distribution = editSession.getBlockDistribution(session.getRegion()); + Logger logger = Logger.getLogger("Minecraft.WorldEdit"); + if (distribution.size() > 0) { // *Should* always be true int size = session.getRegion().getSize(); player.print("# total blocks: " + size); + if (args.hasFlag('c')) { + logger.info("Block distribution (req. by " + player.getName() + "):"); + logger.info("# total blocks: " + size); + } + for (Countable c : distribution) { - player.print(String.format("%-7s (%.3f%%) %s #%d", + String str = String.format("%-7s (%.3f%%) %s #%d", String.valueOf(c.getAmount()), c.getAmount() / (double)size * 100, - BlockType.fromID(c.getID()).getName(), c.getID())); + BlockType.fromID(c.getID()).getName(), c.getID()); + player.print(str); + + if (args.hasFlag('c')) { + logger.info(str); + } } } else { player.printError("No blocks counted.");