diff --git a/build.gradle b/build.gradle index 2a9aa2a..cb45c81 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ import groovy.io.FileType apply plugin: 'java-library' apply plugin: 'maven' -version = '0.1.13' +version = '0.1.14' group = 'com.mojang' task wrapper(type: Wrapper) { diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java index 9942a21..392e55d 100644 --- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java +++ b/src/main/java/com/mojang/brigadier/CommandDispatcher.java @@ -10,6 +10,7 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContextBuilder; import com.mojang.brigadier.context.StringRange; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.ParameterizedCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; @@ -33,7 +34,7 @@ public class CommandDispatcher { public static final SimpleCommandExceptionType ERROR_UNKNOWN_COMMAND = new SimpleCommandExceptionType("command.unknown.command", "Unknown command"); public static final SimpleCommandExceptionType ERROR_UNKNOWN_ARGUMENT = new SimpleCommandExceptionType("command.unknown.argument", "Incorrect argument for command"); public static final SimpleCommandExceptionType ERROR_EXPECTED_ARGUMENT_SEPARATOR = new SimpleCommandExceptionType("command.expected.separator", "Expected whitespace to end one argument, but found trailing data"); - public static final SimpleCommandExceptionType ERROR_COMMAND_FAILED = new SimpleCommandExceptionType("command.failed", "Expected whitespace to end one argument, but found trailing data"); + public static final ParameterizedCommandExceptionType ERROR_PARSE_EXCEPTION = new ParameterizedCommandExceptionType("command.exception", "Could not parse command: ${message}", "message"); public static final String ARGUMENT_SEPARATOR = " "; public static final char ARGUMENT_SEPARATOR_CHAR = ' '; @@ -166,7 +167,11 @@ public class CommandDispatcher { final CommandContextBuilder context = contextSoFar.copy(); final StringReader reader = new StringReader(originalReader); try { - child.parse(reader, context); + try { + child.parse(reader, context); + } catch (final RuntimeException ex) { + throw ERROR_PARSE_EXCEPTION.createWithContext(reader, ex.getMessage()); + } if (reader.canRead()) { if (reader.peek() != ARGUMENT_SEPARATOR_CHAR) { throw ERROR_EXPECTED_ARGUMENT_SEPARATOR.createWithContext(reader);