Commands should return an int success count
This commit is contained in:
@@ -2,6 +2,9 @@ package com.mojang.brigadier;
|
||||
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Command<S> {
|
||||
void run(CommandContext<S> context);
|
||||
int SINGLE_SUCCESS = 1;
|
||||
|
||||
int run(CommandContext<S> context);
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ public class CommandDispatcher<S> {
|
||||
root.addChild(command.build());
|
||||
}
|
||||
|
||||
public void execute(String command, S source) throws CommandException {
|
||||
public int execute(String command, S source) throws CommandException {
|
||||
CommandContext<S> context = parseNodes(root, command, new CommandContextBuilder<>(source));
|
||||
context.getCommand().run(context);
|
||||
return context.getCommand().run(context);
|
||||
}
|
||||
|
||||
private CommandContext<S> parseNodes(CommandNode<S> node, String command, CommandContextBuilder<S> contextBuilder) throws CommandException {
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, ?>> {
|
||||
public abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, T>> {
|
||||
private final RootCommandNode<S> arguments = new RootCommandNode<>();
|
||||
private Command<S> command;
|
||||
private Predicate<S> requirement = s -> true;
|
||||
|
||||
Reference in New Issue
Block a user