Added commandbuilder.then() and argumentbuilder
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
package net.minecraft.commands.arguments;
|
||||
|
||||
public interface CommandArgumentType {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.minecraft.commands.arguments;
|
||||
|
||||
public class IntegerArgumentType implements CommandArgumentType {
|
||||
private final int minimum;
|
||||
private final int maximum;
|
||||
|
||||
protected IntegerArgumentType(int minimum, int maximum) {
|
||||
this.minimum = minimum;
|
||||
this.maximum = maximum;
|
||||
}
|
||||
|
||||
public static IntegerArgumentType integer() {
|
||||
return integer(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
public static IntegerArgumentType integer(int min) {
|
||||
return integer(min, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public static IntegerArgumentType integer(int min, int max) {
|
||||
return new IntegerArgumentType(min, max);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
package net.minecraft.commands.arguments;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ArgumentBuilder {
|
||||
private final List<ArgumentBuilder> arguments = Lists.newArrayList();
|
||||
|
||||
public ArgumentBuilder then(ArgumentBuilder argument) {
|
||||
arguments.add(argument);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ArgumentBuilder> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBuilder {
|
||||
private final String name;
|
||||
private final List<ArgumentBuilder> arguments = Lists.newArrayList();
|
||||
private Runnable executor;
|
||||
|
||||
protected CommandBuilder(String name) {
|
||||
@@ -24,4 +29,13 @@ public class CommandBuilder {
|
||||
public Runnable getExecutor() {
|
||||
return executor;
|
||||
}
|
||||
|
||||
public CommandBuilder then(ArgumentBuilder argument) {
|
||||
arguments.add(argument);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ArgumentBuilder> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import net.minecraft.commands.arguments.CommandArgumentType;
|
||||
|
||||
public class RequiredArgumentBuilder extends ArgumentBuilder {
|
||||
private final String name;
|
||||
private final CommandArgumentType type;
|
||||
|
||||
protected RequiredArgumentBuilder(String name, CommandArgumentType type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static RequiredArgumentBuilder argument(String name, CommandArgumentType type) {
|
||||
return new RequiredArgumentBuilder(name, type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user