Extracted " " into a constant for separating arguments
This commit is contained in:
@@ -10,6 +10,8 @@ import net.minecraft.commands.tree.CommandNode;
|
|||||||
import net.minecraft.commands.tree.RootCommandNode;
|
import net.minecraft.commands.tree.RootCommandNode;
|
||||||
|
|
||||||
public class CommandDispatcher {
|
public class CommandDispatcher {
|
||||||
|
public static final String ARGUMENT_SEPARATOR = " ";
|
||||||
|
|
||||||
private final RootCommandNode root = new RootCommandNode();
|
private final RootCommandNode root = new RootCommandNode();
|
||||||
|
|
||||||
public void register(LiteralArgumentBuilder command) {
|
public void register(LiteralArgumentBuilder command) {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package net.minecraft.commands.arguments;
|
package net.minecraft.commands.arguments;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
import net.minecraft.commands.CommandDispatcher;
|
||||||
import net.minecraft.commands.context.CommandContext;
|
import net.minecraft.commands.context.CommandContext;
|
||||||
import net.minecraft.commands.context.ParsedArgument;
|
import net.minecraft.commands.context.ParsedArgument;
|
||||||
import net.minecraft.commands.exceptions.ArgumentValidationException;
|
import net.minecraft.commands.exceptions.ArgumentValidationException;
|
||||||
import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException;
|
import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException;
|
||||||
|
|
||||||
public class IntegerArgumentType implements CommandArgumentType<Integer> {
|
public class IntegerArgumentType implements CommandArgumentType<Integer> {
|
||||||
private static final Splitter SPLITTER = Splitter.on(' ').limit(2);
|
private static final Splitter SPLITTER = Splitter.on(CommandDispatcher.ARGUMENT_SEPARATOR).limit(2);
|
||||||
|
|
||||||
private final int minimum;
|
private final int minimum;
|
||||||
private final int maximum;
|
private final int maximum;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.minecraft.commands.tree;
|
package net.minecraft.commands.tree;
|
||||||
|
|
||||||
import net.minecraft.commands.Command;
|
import net.minecraft.commands.Command;
|
||||||
|
import net.minecraft.commands.CommandDispatcher;
|
||||||
import net.minecraft.commands.context.CommandContextBuilder;
|
import net.minecraft.commands.context.CommandContextBuilder;
|
||||||
import net.minecraft.commands.exceptions.ArgumentValidationException;
|
import net.minecraft.commands.exceptions.ArgumentValidationException;
|
||||||
import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException;
|
import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException;
|
||||||
@@ -19,7 +20,7 @@ public class LiteralCommandNode extends CommandNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String parse(String command, CommandContextBuilder contextBuilder) throws IllegalArgumentSyntaxException, ArgumentValidationException {
|
public String parse(String command, CommandContextBuilder contextBuilder) throws IllegalArgumentSyntaxException, ArgumentValidationException {
|
||||||
String expected = literal + (command.length() > literal.length() ? " " : "");
|
String expected = literal + (command.length() > literal.length() ? CommandDispatcher.ARGUMENT_SEPARATOR : "");
|
||||||
|
|
||||||
if (!command.startsWith(expected)) {
|
if (!command.startsWith(expected)) {
|
||||||
throw new IllegalArgumentSyntaxException();
|
throw new IllegalArgumentSyntaxException();
|
||||||
|
|||||||
Reference in New Issue
Block a user