Made every CommandNode support an executor
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user