Skip to content

Commit bf10049

Browse files
committed
Fix wrong error thrown
1 parent 8e07ad3 commit bf10049

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bluecommands-brigadier/src/main/java/de/bluecolored/bluecommands/brigadier/DefaultExecutionHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package de.bluecolored.bluecommands.brigadier;
2626

27+
import com.mojang.brigadier.Message;
2728
import com.mojang.brigadier.exceptions.CommandSyntaxException;
2829
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
2930
import de.bluecolored.bluecommands.ParseFailure;
@@ -33,6 +34,7 @@
3334
import java.util.Comparator;
3435

3536
public class DefaultExecutionHandler<C, T> implements CommandExecutionHandler<C, T> {
37+
private static final Message DEFAULT_FAILURE_MESSAGE = () -> "Unknown or incomplete command!";
3638

3739
@Override
3840
public int handle(ParseResult<C, T> parseResult) throws CommandSyntaxException {
@@ -56,7 +58,10 @@ public int handle(ParseResult<C, T> parseResult) throws CommandSyntaxException {
5658
public int handleParseFailure(ParseResult<C, T> result) throws CommandSyntaxException {
5759
ParseFailure<C, ?> failure = result.getFailures().stream()
5860
.max(Comparator.comparing(ParseFailure::getPosition))
59-
.orElseThrow(IllegalAccessError::new);
61+
.orElseThrow(() -> new CommandSyntaxException(
62+
new SimpleCommandExceptionType(DEFAULT_FAILURE_MESSAGE),
63+
DEFAULT_FAILURE_MESSAGE
64+
));
6065
throw new CommandSyntaxException(
6166
new SimpleCommandExceptionType(failure::getReason),
6267
failure::getReason,

0 commit comments

Comments
 (0)