diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetsMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetsMask.java index 7402ddf03..3d5b414b7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetsMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetsMask.java @@ -22,7 +22,8 @@ package com.sk89q.worldedit.function.mask; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.sk89q.worldedit.EditSessionBuilder; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction.Flag; @@ -43,6 +44,17 @@ public class OffsetsMask extends AbstractMask { .map(Direction::toBlockVector) .collect(ImmutableSet.toImmutableSet()); + /** + * Create an offsets mask for a single offset. + * + * @param mask the mask to use + * @param offset the offset + * @return the new offsets mask + */ + public static OffsetsMask single(Mask mask, BlockVector3 offset) { + return builder(mask).maxMatches(1).offsets(ImmutableList.of(offset)).build(); + } + //FAWE start /** * Create an offsets mask for a single offset. @@ -58,6 +70,7 @@ public class OffsetsMask extends AbstractMask { } //FAWE end + /** * Create a new builder, using the given mask. * @param mask the mask to use @@ -176,7 +189,14 @@ public class OffsetsMask extends AbstractMask { private final int maxMatches; private final ImmutableSet offsets; + //FAWE start - ignore resultant position outside world height range + private OffsetsMask(Mask mask, boolean excludeSelf, int minMatches, int maxMatches, ImmutableSet offsets) { + this(mask, excludeSelf, minMatches, maxMatches, offsets, + WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).versionMinY(), + WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).versionMaxY()); + } + private OffsetsMask(Mask mask, boolean excludeSelf, int minMatches, int maxMatches, ImmutableSet offsets, int minY, int maxY) { checkNotNull(mask); checkNotNull(offsets);