From 9cd164ae98428e0b07a1a6f3ac13a463ab2f01bf Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 27 Mar 2014 21:11:02 -0700 Subject: [PATCH] Removed mask support from BlockCount. RegionMaskFilter handles it. --- .../java/com/sk89q/worldedit/EditSession.java | 7 ++++--- .../sk89q/worldedit/operation/BlockCount.java | 21 ++----------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index aa1c5b040..d041591ce 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -551,10 +551,11 @@ public class EditSession { */ public int countBlocks(Region region, Set searchBlocks) { FuzzyBlockMask mask = new FuzzyBlockMask(searchBlocks); - BlockCount counter = new BlockCount(this, mask); - RegionVisitor visitor = new RegionVisitor(region, counter); + BlockCount count = new BlockCount(); + RegionMaskFilter filter = new RegionMaskFilter(this, mask, count); + RegionVisitor visitor = new RegionVisitor(region, filter); OperationHelper.completeBlindly(visitor); // We can't throw exceptions, nor do we expect any - return counter.getCount(); + return count.getCount(); } /** diff --git a/src/main/java/com/sk89q/worldedit/operation/BlockCount.java b/src/main/java/com/sk89q/worldedit/operation/BlockCount.java index 3ac2533e6..9482d141c 100644 --- a/src/main/java/com/sk89q/worldedit/operation/BlockCount.java +++ b/src/main/java/com/sk89q/worldedit/operation/BlockCount.java @@ -19,30 +19,15 @@ package com.sk89q.worldedit.operation; -import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.masks.Mask; /** - * Counts the number of blocks that match a given mask. + * Counts the number of blocks. */ public class BlockCount implements RegionFunction { - private final EditSession editSession; - private Mask mask; private int count; - - /** - * Create a new block counter. - * - * @param editSession the edit session - * @param mask the mask - */ - public BlockCount(EditSession editSession, Mask mask) { - this.editSession = editSession; - this.mask = mask; - } /** * Returns the number of blocks that have been counted. @@ -55,9 +40,7 @@ import com.sk89q.worldedit.masks.Mask; @Override public boolean apply(Vector position) throws WorldEditException { - if (mask.matches(editSession, position)) { - count++; - } + count++; return false; }