From ebd27781a7f86352149299e39b9adaa2365926a6 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 16 Aug 2018 23:38:56 +1000 Subject: [PATCH] Catch pattern syntax --- .../extension/factory/DefaultMaskParser.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java index 4c1e2f741..a75a27fb4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.*; import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; public class DefaultMaskParser extends FaweParser { private final Dispatcher dispatcher; @@ -115,18 +116,22 @@ public class DefaultMaskParser extends FaweParser { mask = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context); } else { List entries = entry.getValue(); - BlockMaskBuilder builder = new BlockMaskBuilder().addRegex(pe.full); - if (builder.isEmpty()) { - try { - context.setPreferringWildcard(true); - context.setRestricted(false); - BlockStateHolder block = worldEdit.getBlockFactory().parseFromInput(pe.full, context); - builder.add(block); - } catch (NoMatchException e) { - throw new NoMatchException(e.getMessage() + " See: //masks"); + try { + BlockMaskBuilder builder = new BlockMaskBuilder().addRegex(pe.full); + if (builder.isEmpty()) { + try { + context.setPreferringWildcard(true); + context.setRestricted(false); + BlockStateHolder block = worldEdit.getBlockFactory().parseFromInput(pe.full, context); + builder.add(block); + } 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); } } }