2222import com .google .common .collect .ImmutableList ;
2323import com .google .common .collect .ImmutableSet ;
2424import com .google .common .collect .Iterables ;
25- import com .sk89q .worldedit .EditSessionBuilder ;
25+ import com .sk89q .worldedit .WorldEdit ;
26+ import com .sk89q .worldedit .extension .platform .Capability ;
2627import com .sk89q .worldedit .math .BlockVector3 ;
2728import com .sk89q .worldedit .util .Direction ;
2829import com .sk89q .worldedit .util .Direction .Flag ;
@@ -43,6 +44,17 @@ public class OffsetsMask extends AbstractMask {
4344 .map (Direction ::toBlockVector )
4445 .collect (ImmutableSet .toImmutableSet ());
4546
47+ /**
48+ * Create an offsets mask for a single offset.
49+ *
50+ * @param mask the mask to use
51+ * @param offset the offset
52+ * @return the new offsets mask
53+ */
54+ public static OffsetsMask single (Mask mask , BlockVector3 offset ) {
55+ return builder (mask ).maxMatches (1 ).offsets (ImmutableList .of (offset )).build ();
56+ }
57+
4658 //FAWE start
4759 /**
4860 * Create an offsets mask for a single offset.
@@ -58,6 +70,7 @@ public static OffsetsMask single(Mask mask, BlockVector3 offset, int minY, int m
5870 }
5971 //FAWE end
6072
73+
6174 /**
6275 * Create a new builder, using the given mask.
6376 * @param mask the mask to use
@@ -176,7 +189,14 @@ public OffsetsMask build() {
176189 private final int maxMatches ;
177190 private final ImmutableSet <BlockVector3 > offsets ;
178191
192+
179193 //FAWE start - ignore resultant position outside world height range
194+ private OffsetsMask (Mask mask , boolean excludeSelf , int minMatches , int maxMatches , ImmutableSet <BlockVector3 > offsets ) {
195+ this (mask , excludeSelf , minMatches , maxMatches , offsets ,
196+ WorldEdit .getInstance ().getPlatformManager ().queryCapability (Capability .WORLD_EDITING ).versionMinY (),
197+ WorldEdit .getInstance ().getPlatformManager ().queryCapability (Capability .WORLD_EDITING ).versionMaxY ());
198+ }
199+
180200 private OffsetsMask (Mask mask , boolean excludeSelf , int minMatches , int maxMatches , ImmutableSet <BlockVector3 > offsets , int minY , int maxY ) {
181201 checkNotNull (mask );
182202 checkNotNull (offsets );
0 commit comments