Introduced AbstractMask as a superclass to all implementors of the Mask interface.

Dieser Commit ist enthalten in:
TomyLobo 2013-10-19 11:43:01 +02:00
Ursprung 6e3d8395df
Commit 02de320980
10 geänderte Dateien mit 22 neuen und 35 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,11 @@
package com.sk89q.worldedit.masks;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
public abstract class AbstractMask implements Mask {
@Override
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
}
}

Datei anzeigen

@ -5,12 +5,10 @@ import java.util.Set;
import com.sk89q.worldedit.BiomeType; import com.sk89q.worldedit.BiomeType;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
public class BiomeTypeMask implements Mask { public class BiomeTypeMask extends AbstractMask {
private final Set<BiomeType> biomes; private final Set<BiomeType> biomes;
public BiomeTypeMask() { public BiomeTypeMask() {
@ -21,9 +19,6 @@ public class BiomeTypeMask implements Mask {
this.biomes = biomes; this.biomes = biomes;
} }
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
}
public boolean matches2D(EditSession editSession, Vector2D pos) { public boolean matches2D(EditSession editSession, Vector2D pos) {
BiomeType biome = editSession.getWorld().getBiome(pos); BiomeType biome = editSession.getWorld().getBiome(pos);
return biomes.contains(biome); return biomes.contains(biome);

Datei anzeigen

@ -5,12 +5,10 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
public class BlockMask implements Mask { public class BlockMask extends AbstractMask {
private final Set<BaseBlock> blocks; private final Set<BaseBlock> blocks;
public BlockMask() { public BlockMask() {
@ -34,9 +32,6 @@ public class BlockMask implements Mask {
blocks.addAll(blocks); blocks.addAll(blocks);
} }
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
}
@Override @Override
public boolean matches(EditSession editSession, Vector pos) { public boolean matches(EditSession editSession, Vector pos) {
BaseBlock block = editSession.getBlock(pos); BaseBlock block = editSession.getBlock(pos);

Datei anzeigen

@ -26,7 +26,7 @@ import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
public class CombinedMask implements Mask { public class CombinedMask extends AbstractMask {
private final List<Mask> masks = new ArrayList<Mask>(); private final List<Mask> masks = new ArrayList<Mask>();
public CombinedMask() { public CombinedMask() {

Datei anzeigen

@ -20,15 +20,10 @@
package com.sk89q.worldedit.masks; package com.sk89q.worldedit.masks;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
public class ExistingBlockMask implements Mask { public class ExistingBlockMask extends AbstractMask {
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
}
@Override @Override
public boolean matches(EditSession editSession, Vector pos) { public boolean matches(EditSession editSession, Vector pos) {
return editSession.getBlockType(pos) != BlockID.AIR; return editSession.getBlockType(pos) != BlockID.AIR;

Datei anzeigen

@ -5,7 +5,7 @@ import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
public class InvertedMask implements Mask { public class InvertedMask extends AbstractMask {
private final Mask mask; private final Mask mask;
public InvertedMask(Mask mask) { public InvertedMask(Mask mask) {

Datei anzeigen

@ -26,7 +26,9 @@ import com.sk89q.worldedit.Vector;
/** /**
* Base matcher for the block filtering framework. Implementing classes * Base matcher for the block filtering framework. Implementing classes
* can be used to filter blocks to set or replace * can be used to filter blocks to set or replace.
* <p>
* <u>Do NOT</u> implement this interface. Extend {@link AbstractMask} instead.
* *
* @author sk89q * @author sk89q
*/ */

Datei anzeigen

@ -1,21 +1,15 @@
package com.sk89q.worldedit.masks; package com.sk89q.worldedit.masks;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
public class RandomMask implements Mask { public class RandomMask extends AbstractMask {
private final double ratio; private final double ratio;
public RandomMask(double ratio) { public RandomMask(double ratio) {
this.ratio = ratio; this.ratio = ratio;
} }
@Override
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
}
@Override @Override
public boolean matches(EditSession editSession, Vector pos) { public boolean matches(EditSession editSession, Vector pos) {
return Math.random() < ratio; return Math.random() < ratio;

Datei anzeigen

@ -20,21 +20,16 @@
package com.sk89q.worldedit.masks; package com.sk89q.worldedit.masks;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
public class RegionMask implements Mask { public class RegionMask extends AbstractMask {
private final Region region; private final Region region;
public RegionMask(Region region) { public RegionMask(Region region) {
this.region = region.clone(); this.region = region.clone();
} }
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
}
@Override @Override
public boolean matches(EditSession editSession, Vector pos) { public boolean matches(EditSession editSession, Vector pos) {
return region.contains(pos); return region.contains(pos);

Datei anzeigen

@ -31,7 +31,7 @@ import com.sk89q.worldedit.blocks.BaseBlock;
* *
* @author 1337 * @author 1337
*/ */
public class UnderOverlayMask implements Mask { public class UnderOverlayMask extends AbstractMask {
private final int yMod; private final int yMod;
private Mask mask; private Mask mask;