Added ArgumentCommand#setOnlyCorrect to force correct syntax

This commit is contained in:
themode 2021-03-15 10:13:53 +01:00
parent 78e12879b4
commit 826b1aa6cd

View File

@ -13,6 +13,7 @@ public class ArgumentCommand extends Argument<CommandResult> {
public static final int INVALID_COMMAND_ERROR = 1;
private boolean onlyCorrect;
private String shortcut = "";
public ArgumentCommand(@NotNull String id) {
@ -28,7 +29,7 @@ public class ArgumentCommand extends Argument<CommandResult> {
CommandDispatcher dispatcher = MinecraftServer.getCommandManager().getDispatcher();
CommandResult result = dispatcher.parse(commandString);
if (result.getType() != CommandResult.Type.SUCCESS)
if (onlyCorrect && result.getType() != CommandResult.Type.SUCCESS)
throw new ArgumentSyntaxException("Invalid command", input, INVALID_COMMAND_ERROR);
return result;
@ -53,6 +54,15 @@ public class ArgumentCommand extends Argument<CommandResult> {
}
}
public boolean isOnlyCorrect() {
return onlyCorrect;
}
public ArgumentCommand setOnlyCorrect(boolean onlyCorrect) {
this.onlyCorrect = onlyCorrect;
return this;
}
@NotNull
public String getShortcut() {
return shortcut;