Build stuff into nodes! They may not do anything, but it's node-tastic!
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.commands.tree.CommandNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,4 +16,6 @@ public abstract class ArgumentBuilder {
|
||||
public List<ArgumentBuilder> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public abstract CommandNode build();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.commands.tree.LiteralCommandNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,4 +39,14 @@ public class CommandBuilder {
|
||||
public List<ArgumentBuilder> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public LiteralCommandNode build() {
|
||||
LiteralCommandNode result = new LiteralCommandNode(getName());
|
||||
|
||||
for (ArgumentBuilder argument : arguments) {
|
||||
result.addChild(argument.build());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import net.minecraft.commands.arguments.CommandArgumentType;
|
||||
import net.minecraft.commands.tree.ArgumentCommandNode;
|
||||
|
||||
public class RequiredArgumentBuilder extends ArgumentBuilder {
|
||||
private final String name;
|
||||
@@ -14,4 +15,22 @@ public class RequiredArgumentBuilder extends ArgumentBuilder {
|
||||
public static RequiredArgumentBuilder argument(String name, CommandArgumentType type) {
|
||||
return new RequiredArgumentBuilder(name, type);
|
||||
}
|
||||
|
||||
public CommandArgumentType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArgumentCommandNode build() {
|
||||
ArgumentCommandNode result = new ArgumentCommandNode(getName(), getType());
|
||||
|
||||
for (ArgumentBuilder argument : getArguments()) {
|
||||
result.addChild(argument.build());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.minecraft.commands.tree;
|
||||
|
||||
import net.minecraft.commands.arguments.CommandArgumentType;
|
||||
|
||||
public class ArgumentCommandNode extends CommandNode {
|
||||
private final String name;
|
||||
private final CommandArgumentType type;
|
||||
|
||||
public ArgumentCommandNode(String name, CommandArgumentType type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CommandArgumentType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.minecraft.commands.tree;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class CommandNode {
|
||||
private final List<CommandNode> children = Lists.newArrayList();
|
||||
|
||||
public List<CommandNode> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void addChild(CommandNode node) {
|
||||
children.add(node);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.minecraft.commands.tree;
|
||||
|
||||
public class LiteralCommandNode extends CommandNode {
|
||||
private final String literal;
|
||||
|
||||
public LiteralCommandNode(String literal) {
|
||||
this.literal = literal;
|
||||
}
|
||||
|
||||
public String getLiteral() {
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
package net.minecraft.commands.tree;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
Reference in New Issue
Block a user