Made every CommandNode support an executor

This commit is contained in:
Nathan Adams
2014-09-24 12:04:33 +02:00
parent 3ef22ef317
commit d13587a4df
6 changed files with 34 additions and 8 deletions
@@ -8,7 +8,8 @@ public class ArgumentCommandNode<T> extends CommandNode {
private final String name;
private final CommandArgumentType<T> type;
public ArgumentCommandNode(String name, CommandArgumentType<T> type) {
public ArgumentCommandNode(String name, CommandArgumentType<T> type, Runnable executor) {
super(executor);
this.name = name;
this.type = type;
}
@@ -7,8 +7,17 @@ import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException;
import java.util.List;
public abstract class CommandNode {
private final Runnable executor;
private final List<CommandNode> children = Lists.newArrayList();
protected CommandNode(Runnable executor) {
this.executor = executor;
}
public Runnable getExecutor() {
return executor;
}
public List<CommandNode> getChildren() {
return children;
}
@@ -5,21 +5,16 @@ import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException;
public class LiteralCommandNode extends CommandNode {
private final String literal;
private final Runnable executor;
public LiteralCommandNode(String literal, Runnable executor) {
super(executor);
this.literal = literal;
this.executor = executor;
}
public String getLiteral() {
return literal;
}
public Runnable getExecutor() {
return executor;
}
@Override
public CommandNode parse(String command) throws IllegalArgumentSyntaxException, ArgumentValidationException {
if (command.startsWith(literal)) {