mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Added -c flag to //distr to print to console.
This commit is contained in:
parent
5642f95962
commit
fd4b167ac7
@ -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<Countable<Integer>> 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<Integer> 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.");
|
||||
|
Loading…
Reference in New Issue
Block a user