Commands can be parsed, in a very limited way.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package net.minecraft.commands.tree;
|
||||
|
||||
import net.minecraft.commands.arguments.CommandArgumentType;
|
||||
import net.minecraft.commands.exceptions.IllegalCommandArgumentException;
|
||||
|
||||
public class ArgumentCommandNode extends CommandNode {
|
||||
public class ArgumentCommandNode<T> extends CommandNode {
|
||||
private final String name;
|
||||
private final CommandArgumentType type;
|
||||
private final CommandArgumentType<T> type;
|
||||
|
||||
public ArgumentCommandNode(String name, CommandArgumentType type) {
|
||||
public ArgumentCommandNode(String name, CommandArgumentType<T> type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
@@ -15,7 +16,12 @@ public class ArgumentCommandNode extends CommandNode {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CommandArgumentType getType() {
|
||||
public CommandArgumentType<T> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parse(String command) throws IllegalCommandArgumentException {
|
||||
type.parse(command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.minecraft.commands.tree;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.commands.exceptions.IllegalCommandArgumentException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,4 +15,6 @@ public abstract class CommandNode {
|
||||
public void addChild(CommandNode node) {
|
||||
children.add(node);
|
||||
}
|
||||
|
||||
public abstract void parse(String command) throws IllegalCommandArgumentException;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.commands.tree;
|
||||
|
||||
import net.minecraft.commands.exceptions.IllegalCommandArgumentException;
|
||||
|
||||
public class LiteralCommandNode extends CommandNode {
|
||||
private final String literal;
|
||||
private final Runnable executor;
|
||||
@@ -16,4 +18,11 @@ public class LiteralCommandNode extends CommandNode {
|
||||
public Runnable getExecutor() {
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parse(String command) throws IllegalCommandArgumentException {
|
||||
if (!command.equals(literal)) {
|
||||
throw new IllegalCommandArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user