3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-27 03:12:37 +01:00

Removed mask support from BlockCount.

RegionMaskFilter handles it.
Dieser Commit ist enthalten in:
sk89q 2014-03-27 21:11:02 -07:00
Ursprung a6e979ec6c
Commit 9cd164ae98
2 geänderte Dateien mit 6 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -551,10 +551,11 @@ public class EditSession {
*/ */
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) { public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
FuzzyBlockMask mask = new FuzzyBlockMask(searchBlocks); FuzzyBlockMask mask = new FuzzyBlockMask(searchBlocks);
BlockCount counter = new BlockCount(this, mask); BlockCount count = new BlockCount();
RegionVisitor visitor = new RegionVisitor(region, counter); 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 OperationHelper.completeBlindly(visitor); // We can't throw exceptions, nor do we expect any
return counter.getCount(); return count.getCount();
} }
/** /**

Datei anzeigen

@ -19,30 +19,15 @@
package com.sk89q.worldedit.operation; package com.sk89q.worldedit.operation;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; 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 { public class BlockCount implements RegionFunction {
private final EditSession editSession;
private Mask mask;
private int count; 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. * Returns the number of blocks that have been counted.
@ -55,9 +40,7 @@ import com.sk89q.worldedit.masks.Mask;
@Override @Override
public boolean apply(Vector position) throws WorldEditException { public boolean apply(Vector position) throws WorldEditException {
if (mask.matches(editSession, position)) { count++;
count++;
}
return false; return false;
} }