fix: require extent for mask parsing (#1373)

(cherry picked from commit 1ced57c301bc1c98667a260fd8b6aa128675f0d2)
This commit is contained in:
Matthew Miller 2020-06-24 03:50:32 -04:00 committed by MattBDev
parent c0bfe06e4b
commit 39439fb405
8 changed files with 13 additions and 11 deletions

View File

@ -77,6 +77,6 @@ public class BiomeMaskParser extends InputParser<Mask> {
biomes.add(biome);
}
return Masks.asMask(new BiomeMask2D(context.getExtent(), biomes));
return Masks.asMask(new BiomeMask2D(context.requireExtent(), biomes));
}
}

View File

@ -53,7 +53,7 @@ public class BlockCategoryMaskParser extends InputParser<Mask> {
if (category == null) {
throw new InputParseException("Unrecognised tag '" + input.substring(2) + '\'');
} else {
return new BlockCategoryMask(context.getExtent(), category);
return new BlockCategoryMask(context.requireExtent(), category);
}
}
}

View File

@ -52,7 +52,7 @@ public class BlockStateMaskParser extends InputParser<Mask> {
boolean strict = input.charAt(1) == '=';
String states = input.substring(2 + (strict ? 1 : 0), input.length() - 1);
try {
return new BlockStateMask(context.getExtent(),
return new BlockStateMask(context.requireExtent(),
Splitter.on(',').omitEmptyStrings().trimResults().withKeyValueSeparator('=').split(states),
strict);
} catch (Exception e) {

View File

@ -55,8 +55,8 @@ public class BlocksMaskParser extends InputParser<Mask> {
if (holders.isEmpty()) {
return null;
}
return new BlockMask(context.getExtent(), holders);
} catch (InputParseException e) {
return new BlockMask(context.requireExtent(), holders);
} catch (NoMatchException e) {
return null;
}
}

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.factory.parser.mask;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
@ -42,7 +43,7 @@ public class ExistingMaskParser extends SimpleInputParser<Mask> {
}
@Override
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new ExistingBlockMask(context.getExtent());
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return new ExistingBlockMask(context.requireExtent());
}
}

View File

@ -57,7 +57,7 @@ public class ExpressionMaskParser extends InputParser<Mask> {
try {
Expression exp = Expression.compile(input.substring(1), "x", "y", "z");
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(
context.getExtent(), Vector3.ONE, Vector3.ZERO);
context.requireExtent(), Vector3.ONE, Vector3.ZERO);
exp.setEnvironment(env);
if (context.getActor() != null) {
SessionOwner owner = context.getActor();

View File

@ -61,7 +61,7 @@ public class OffsetMaskParser extends InputParser<Mask> {
if (input.length() > 1) {
submask = worldEdit.getMaskFactory().parseFromInput(input.substring(1), context);
} else {
submask = new ExistingBlockMask(context.getExtent());
submask = new ExistingBlockMask(context.requireExtent());
}
OffsetMask offsetMask = new OffsetMask(submask, BlockVector3.at(0, firstChar == '>' ? -1 : 1, 0));
return new MaskIntersection(offsetMask, Masks.negate(submask));

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.factory.parser.mask;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
@ -42,7 +43,7 @@ public class SolidMaskParser extends SimpleInputParser<Mask> {
}
@Override
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new SolidBlockMask(context.getExtent());
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return new SolidBlockMask(context.requireExtent());
}
}