General code cleanup.

This commit is contained in:
sk89q
2014-03-31 20:29:05 -07:00
parent 8bec48dc9e
commit 761904e496
16 changed files with 97 additions and 43 deletions

View File

@ -26,6 +26,9 @@ import com.sk89q.worldedit.function.mask.Mask;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Requires that all mutating methods pass a given {@link Mask}.
*/
public class MaskingExtent extends ExtentDelegate {
private Mask mask;
@ -63,11 +66,7 @@ public class MaskingExtent extends ExtentDelegate {
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
if (mask.test(location)) {
return super.setBlock(location, block);
} else {
return false;
}
return mask.test(location) && super.setBlock(location, block);
}
}

View File

@ -39,7 +39,7 @@ import java.util.*;
/**
* Re-orders blocks into several stages.
*/
public class SimpleBlockReorder extends ExtentDelegate {
public class MultiStageReorder extends ExtentDelegate implements ReorderingExtent {
private TupleArrayList<BlockVector, BaseBlock> stage1 = new TupleArrayList<BlockVector, BaseBlock>();
private TupleArrayList<BlockVector, BaseBlock> stage2 = new TupleArrayList<BlockVector, BaseBlock>();
@ -52,7 +52,7 @@ public class SimpleBlockReorder extends ExtentDelegate {
* @param extent the extent
* @param enabled true to enable
*/
public SimpleBlockReorder(Extent extent, boolean enabled) {
public MultiStageReorder(Extent extent, boolean enabled) {
super(extent);
this.enabled = enabled;
}
@ -62,7 +62,7 @@ public class SimpleBlockReorder extends ExtentDelegate {
*
* @param extent the extent
*/
public SimpleBlockReorder(Extent extent) {
public MultiStageReorder(Extent extent) {
this(extent, true);
}

View File

@ -0,0 +1,34 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent.reorder;
import com.sk89q.worldedit.extent.Extent;
/**
* An interface for {@link Extent}s that are meant to reorder changes so
* that they are more successful.
* </p>
* For example, torches in Minecraft need to be placed on a block. A smart
* reordering implementation might place the torch after the block has
* been placed.
*/
public interface ReorderingExtent extends Extent {
}