Catch pattern syntax

This commit is contained in:
Jesse Boyd 2018-08-16 23:38:56 +10:00
parent 4ffb9bce6c
commit ebd27781a7
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -24,6 +24,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
public class DefaultMaskParser extends FaweParser<Mask> { public class DefaultMaskParser extends FaweParser<Mask> {
private final Dispatcher dispatcher; private final Dispatcher dispatcher;
@ -115,18 +116,22 @@ public class DefaultMaskParser extends FaweParser<Mask> {
mask = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context); mask = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context);
} else { } else {
List<String> entries = entry.getValue(); List<String> entries = entry.getValue();
BlockMaskBuilder builder = new BlockMaskBuilder().addRegex(pe.full); try {
if (builder.isEmpty()) { BlockMaskBuilder builder = new BlockMaskBuilder().addRegex(pe.full);
try { if (builder.isEmpty()) {
context.setPreferringWildcard(true); try {
context.setRestricted(false); context.setPreferringWildcard(true);
BlockStateHolder block = worldEdit.getBlockFactory().parseFromInput(pe.full, context); context.setRestricted(false);
builder.add(block); BlockStateHolder block = worldEdit.getBlockFactory().parseFromInput(pe.full, context);
} catch (NoMatchException e) { builder.add(block);
throw new NoMatchException(e.getMessage() + " See: //masks"); } catch (NoMatchException e) {
throw new NoMatchException(e.getMessage() + " See: //masks");
}
} }
mask = builder.build(extent);
} catch (PatternSyntaxException regex) {
throw new InputParseException(regex.getMessage());
} }
mask = builder.build(extent);
} }
} }
} }