backwards compatibility for public constructors

This commit is contained in:
NeunEinser 2018-10-22 12:14:57 +02:00
parent 95c8378bb5
commit 93867b16d2
7 changed files with 23 additions and 14 deletions

View file

@ -560,11 +560,11 @@ public class CommandDispatcher<S> {
return self;
}
private boolean isNodeExecutable(CommandNode<S> defaultNode) {
while (defaultNode.getCommand() == null && defaultNode.getDefaultNode() != null)
defaultNode = defaultNode.getDefaultNode();
private boolean isNodeExecutable(CommandNode<S> node) {
while (node.getCommand() == null && node.getDefaultNode() != null)
node = node.getDefaultNode();
return defaultNode.getCommand() != null;
return node.getCommand() != null;
}
/**

View file

@ -33,7 +33,7 @@ public class LiteralArgumentBuilder<S> extends ArgumentBuilder<S, LiteralArgumen
@Override
public LiteralCommandNode<S> build() {
final LiteralCommandNode<S> result = new LiteralCommandNode<>(getLiteral(), getCommand(), getDefaultNode(), isDefaultNode(), getRequirement(), getRedirect(), getRedirectModifier(), isFork());
final LiteralCommandNode<S> result = new LiteralCommandNode<>(getLiteral(), getCommand(), getRequirement(), getRedirect(), getRedirectModifier(), isFork(), getDefaultNode(), isDefaultNode());
for (final CommandNode<S> argument : getArguments()) {
result.addChild(argument);

View file

@ -56,7 +56,7 @@ public class RequiredArgumentBuilder<S, T> extends ArgumentBuilder<S, RequiredAr
}
public ArgumentCommandNode<S, T> build() {
final ArgumentCommandNode<S, T> result = new ArgumentCommandNode<>(getName(), getType(), getCommand(), getDefaultNode(), getDefaultValue(), isDefaultNode(), getRequirement(), getRedirect(), getRedirectModifier(), isFork(), getSuggestionsProvider());
final ArgumentCommandNode<S, T> result = new ArgumentCommandNode<>(getName(), getType(), getCommand(), getRequirement(), getRedirect(), getRedirectModifier(), isFork(), getDefaultNode(), isDefaultNode(), getDefaultValue(), getSuggestionsProvider());
for (final CommandNode<S> argument : getArguments()) {
result.addChild(argument);

View file

@ -28,9 +28,13 @@ public class ArgumentCommandNode<S, T> extends CommandNode<S> {
private final ArgumentType<T> type;
private final SuggestionProvider<S> customSuggestions;
private final T defaultValue;
public ArgumentCommandNode(final String name, final ArgumentType<T> type, final Command<S> command, final CommandNode<S> defaultArgument, final T defaultValue, final boolean isDefaultNode, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final SuggestionProvider<S> customSuggestions) {
super(command, requirement, defaultArgument, isDefaultNode, redirect, modifier, forks);
public ArgumentCommandNode(final String name, final ArgumentType<T> type, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final SuggestionProvider<S> customSuggestions) {
this(name, type, command, requirement, redirect, modifier, forks, null, false, null, customSuggestions);
}
public ArgumentCommandNode(final String name, final ArgumentType<T> type, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final CommandNode<S> defaultNode, final boolean isDefaultNode, final T defaultValue, final SuggestionProvider<S> customSuggestions) {
super(command, requirement, redirect, modifier, forks, defaultNode, isDefaultNode);
this.name = name;
this.type = type;
this.customSuggestions = customSuggestions;

View file

@ -36,7 +36,7 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
private final boolean forks;
private Command<S> command;
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> defaultNode, final boolean isDefaultNode, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final CommandNode<S> defaultNode, final boolean isDefaultNode) {
this.command = command;
this.requirement = requirement;
this.defaultNode = defaultNode;

View file

@ -21,9 +21,14 @@ import java.util.function.Predicate;
public class LiteralCommandNode<S> extends CommandNode<S> {
private final String literal;
public LiteralCommandNode(final String literal, final Command<S> command, final CommandNode<S> defaultArgument, final boolean isDefaultNode, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
super(command, requirement, defaultArgument, isDefaultNode, redirect, modifier, forks);
public LiteralCommandNode(final String literal, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
this(literal, command, requirement, redirect, modifier, forks, null, false);
}
public LiteralCommandNode(final String literal, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final CommandNode<S> defaultArgument, final boolean isDefaultNode) {
super(command, requirement, redirect, modifier, forks, defaultArgument, isDefaultNode);
this.literal = literal;
}

View file

@ -17,7 +17,7 @@ import java.util.concurrent.CompletableFuture;
public class RootCommandNode<S> extends CommandNode<S> {
public RootCommandNode() {
super(null, c -> true, null, false, null, s -> Collections.singleton(s.getSource()), false);
super(null, c -> true, null, s -> Collections.singleton(s.getSource()), false, null, false);
}
@Override