package net.minecraft.commands.tree; import net.minecraft.commands.Command; import net.minecraft.commands.arguments.CommandArgumentType; import net.minecraft.commands.context.ParsedArgument; import net.minecraft.commands.exceptions.ArgumentValidationException; import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException; public class ArgumentCommandNode extends CommandNode { private final String name; private final CommandArgumentType type; public ArgumentCommandNode(String name, CommandArgumentType type, Command command) { super(command); this.name = name; this.type = type; } public String getName() { return name; } public CommandArgumentType getType() { return type; } @Override public CommandNode parse(String command) throws IllegalArgumentSyntaxException, ArgumentValidationException { ParsedArgument parsed = type.parse(command); int start = parsed.getRaw().length() + 1; if (start < command.length()) { String result = command.substring(start); for (CommandNode node : getChildren()) { try { return node.parse(result); } catch (IllegalArgumentSyntaxException ignored) { } } throw new IllegalArgumentSyntaxException(); } else { return this; } } }