From e09a0c64addb5afb64acbf2782dc62cd77296db7 Mon Sep 17 00:00:00 2001 From: Wizjany Date: Fri, 28 Dec 2012 19:26:57 -0500 Subject: [PATCH] Add amount of missing blocks to message when using inventory. --- src/main/java/com/sk89q/worldedit/EditSession.java | 14 +++++++++----- src/main/java/com/sk89q/worldedit/WorldEdit.java | 6 ++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index 085784fa5..071655455 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -124,7 +124,7 @@ public class EditSession { /** * List of missing blocks; */ - private Set missingBlocks = new HashSet(); + private Map missingBlocks = new HashMap(); /** * Mask to cover operations. @@ -208,7 +208,11 @@ public class EditSession { } catch (UnplaceableBlockException e) { return false; } catch (BlockBagException e) { - missingBlocks.add(type); + if (!missingBlocks.containsKey(type)) { + missingBlocks.put(type, 1); + } else { + missingBlocks.put(type, missingBlocks.get(type) + 1); + } return false; } } @@ -606,9 +610,9 @@ public class EditSession { * * @return */ - public Set popMissingBlocks() { - Set missingBlocks = this.missingBlocks; - this.missingBlocks = new HashSet(); + public Map popMissingBlocks() { + Map missingBlocks = this.missingBlocks; + this.missingBlocks = new HashMap(); return missingBlocks; } diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 20eeebda7..93c5688a1 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -1079,7 +1079,7 @@ public class WorldEdit { blockBag.flushChanges(); } - Set missingBlocks = editSession.popMissingBlocks(); + Map missingBlocks = editSession.popMissingBlocks(); if (missingBlocks.size() > 0) { StringBuilder str = new StringBuilder(); @@ -1087,13 +1087,15 @@ public class WorldEdit { int size = missingBlocks.size(); int i = 0; - for (Integer id : missingBlocks) { + for (Integer id : missingBlocks.keySet()) { BlockType type = BlockType.fromID(id); str.append(type != null ? type.getName() + " (" + id + ")" : id.toString()); + str.append(" [Amt: " + missingBlocks.get(id) + "]"); + ++i; if (i != size) {