mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-28 23:44:58 +02:00
Added ArgumentCommand#setOnlyCorrect to force correct syntax
This commit is contained in:
parent
78e12879b4
commit
826b1aa6cd
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user