Add arglength checking for /npc command clearerror

This commit is contained in:
fullwall 2022-10-25 15:58:57 +08:00
parent bbf7ca2f98
commit 353699fe80

View File

@ -441,6 +441,10 @@ public class NPCCommands {
throw new CommandException(CommandMessages.INVALID_NUMBER); throw new CommandException(CommandMessages.INVALID_NUMBER);
} }
} else if (action.equalsIgnoreCase("clearerror")) { } else if (action.equalsIgnoreCase("clearerror")) {
if (args.argsLength() < 3)
throw new CommandException(Messages.NPC_COMMAND_INVALID_ERROR_MESSAGE,
Util.listValuesPretty(CommandTraitError.values()));
CommandTraitError which = Util.matchEnum(CommandTraitError.values(), args.getString(2)); CommandTraitError which = Util.matchEnum(CommandTraitError.values(), args.getString(2));
if (which == null) if (which == null)
throw new CommandException(Messages.NPC_COMMAND_INVALID_ERROR_MESSAGE, throw new CommandException(Messages.NPC_COMMAND_INVALID_ERROR_MESSAGE,