core: Allow attaching a default description to arguments
This commit is contained in:
parent
b38c725dc5
commit
78b081ccc2
29 changed files with 323 additions and 83 deletions
|
|
@ -573,7 +573,7 @@ public class Command<C> {
|
|||
* @return New builder instance with the command argument inserted into the argument list
|
||||
*/
|
||||
public <T> @NonNull Builder<C> argument(final CommandArgument.@NonNull Builder<C, T> builder) {
|
||||
return this.argument(builder.build(), ArgumentDescription.empty());
|
||||
return this.argument(builder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -584,7 +584,7 @@ public class Command<C> {
|
|||
* @return New builder instance with the command argument inserted into the argument list
|
||||
*/
|
||||
public <T> @NonNull Builder<C> argument(final @NonNull CommandArgument<C, T> argument) {
|
||||
return this.argument(argument, ArgumentDescription.empty());
|
||||
return this.argument(argument, argument.getDefaultDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.Command;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
|
|
@ -99,6 +100,12 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
*/
|
||||
private final Collection<BiFunction<@NonNull CommandContext<C>,
|
||||
@NonNull Queue<@NonNull String>, @NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors;
|
||||
|
||||
/**
|
||||
* A description that will be used when registering this argument if no override is provided.
|
||||
*/
|
||||
private final ArgumentDescription defaultDescription;
|
||||
|
||||
/**
|
||||
* Whether or not the argument has been used before
|
||||
*/
|
||||
|
|
@ -106,6 +113,46 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
|
||||
private Command<C> owningCommand;
|
||||
|
||||
/**
|
||||
* Construct a new command argument
|
||||
*
|
||||
* @param required Whether or not the argument is required
|
||||
* @param name The argument name
|
||||
* @param parser The argument parser
|
||||
* @param defaultValue Default value used when no value is provided by the command sender
|
||||
* @param valueType Type produced by the parser
|
||||
* @param suggestionsProvider Suggestions provider
|
||||
* @param defaultDescription Default description to use when registering
|
||||
* @param argumentPreprocessors Argument preprocessors
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public CommandArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull ArgumentParser<C, T> parser,
|
||||
final @NonNull String defaultValue,
|
||||
final @NonNull TypeToken<T> valueType,
|
||||
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription,
|
||||
final @NonNull Collection<@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
|
||||
@NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors
|
||||
) {
|
||||
this.required = required;
|
||||
this.name = Objects.requireNonNull(name, "Name may not be null");
|
||||
if (!NAME_PATTERN.asPredicate().test(name)) {
|
||||
throw new IllegalArgumentException("Name must be alphanumeric");
|
||||
}
|
||||
this.parser = Objects.requireNonNull(parser, "Parser may not be null");
|
||||
this.defaultValue = defaultValue;
|
||||
this.valueType = valueType;
|
||||
this.suggestionsProvider = suggestionsProvider == null
|
||||
? buildDefaultSuggestionsProvider(this)
|
||||
: suggestionsProvider;
|
||||
this.defaultDescription = Objects.requireNonNull(defaultDescription, "Default description may not be null");
|
||||
this.argumentPreprocessors = new LinkedList<>(argumentPreprocessors);
|
||||
this.key = SimpleCloudKey.of(this.name, this.valueType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new command argument
|
||||
*
|
||||
|
|
@ -127,19 +174,16 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
final @NonNull Collection<@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
|
||||
@NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors
|
||||
) {
|
||||
this.required = required;
|
||||
this.name = Objects.requireNonNull(name, "Name may not be null");
|
||||
if (!NAME_PATTERN.asPredicate().test(name)) {
|
||||
throw new IllegalArgumentException("Name must be alphanumeric");
|
||||
}
|
||||
this.parser = Objects.requireNonNull(parser, "Parser may not be null");
|
||||
this.defaultValue = defaultValue;
|
||||
this.valueType = valueType;
|
||||
this.suggestionsProvider = suggestionsProvider == null
|
||||
? buildDefaultSuggestionsProvider(this)
|
||||
: suggestionsProvider;
|
||||
this.argumentPreprocessors = new LinkedList<>(argumentPreprocessors);
|
||||
this.key = SimpleCloudKey.of(this.name, this.valueType);
|
||||
this(
|
||||
required,
|
||||
name,
|
||||
parser,
|
||||
defaultValue,
|
||||
valueType,
|
||||
suggestionsProvider,
|
||||
ArgumentDescription.empty(),
|
||||
argumentPreprocessors
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,6 +207,30 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
this(required, name, parser, defaultValue, valueType, suggestionsProvider, Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new command argument
|
||||
*
|
||||
* @param required Whether or not the argument is required
|
||||
* @param name The argument name
|
||||
* @param parser The argument parser
|
||||
* @param defaultValue Default value used when no value is provided by the command sender
|
||||
* @param valueType Type produced by the parser
|
||||
* @param suggestionsProvider Suggestions provider
|
||||
* @param defaultDescription Default description to use when registering
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public CommandArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull ArgumentParser<C, T> parser,
|
||||
final @NonNull String defaultValue,
|
||||
final @NonNull TypeToken<T> valueType,
|
||||
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
this(required, name, parser, defaultValue, valueType, suggestionsProvider, defaultDescription, Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new command argument
|
||||
*
|
||||
|
|
@ -185,6 +253,31 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
this(required, name, parser, defaultValue, TypeToken.get(valueType), suggestionsProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new command argument
|
||||
*
|
||||
* @param required Whether or not the argument is required
|
||||
* @param name The argument name
|
||||
* @param parser The argument parser
|
||||
* @param defaultValue Default value used when no value is provided by the command sender
|
||||
* @param valueType Type produced by the parser
|
||||
* @param suggestionsProvider Suggestions provider
|
||||
* @param defaultDescription Default description to use when registering
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public CommandArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull ArgumentParser<C, T> parser,
|
||||
final @NonNull String defaultValue,
|
||||
final @NonNull Class<T> valueType,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>,
|
||||
@NonNull String, @NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
this(required, name, parser, defaultValue, TypeToken.get(valueType), suggestionsProvider, defaultDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new command argument
|
||||
*
|
||||
|
|
@ -351,6 +444,15 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
return this.suggestionsProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default description to use when registering and no other is provided.
|
||||
*
|
||||
* @return the default description
|
||||
*/
|
||||
public final @NonNull ArgumentDescription getDefaultDescription() {
|
||||
return this.defaultDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
|
|
@ -429,6 +531,8 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
} else {
|
||||
builder = builder.asOptionalWithDefault(this.defaultValue);
|
||||
}
|
||||
builder = builder.withDefaultDescription(this.defaultDescription);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
@ -465,6 +569,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
private ArgumentParser<C, T> parser;
|
||||
private String defaultValue = "";
|
||||
private BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>> suggestionsProvider;
|
||||
private @NonNull ArgumentDescription defaultDescription = ArgumentDescription.empty();
|
||||
|
||||
private final Collection<BiFunction<@NonNull CommandContext<C>,
|
||||
@NonNull String, @NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors = new LinkedList<>();
|
||||
|
|
@ -565,6 +670,22 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default description to be used for this argument.
|
||||
*
|
||||
* <p>The default description is used when no other description is provided for a certain argument.</p>
|
||||
*
|
||||
* @param defaultDescription The default description
|
||||
* @return Builder instance
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public @NonNull Builder<@NonNull C, @NonNull T> withDefaultDescription(
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
this.defaultDescription = Objects.requireNonNull(defaultDescription, "Default description may not be null");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a command argument from the builder settings
|
||||
*
|
||||
|
|
@ -588,7 +709,8 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
this.parser,
|
||||
this.defaultValue,
|
||||
this.valueType,
|
||||
this.suggestionsProvider
|
||||
this.suggestionsProvider,
|
||||
this.defaultDescription
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -613,6 +735,10 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
|||
return this.suggestionsProvider;
|
||||
}
|
||||
|
||||
protected final @NonNull ArgumentDescription getDefaultDescription() {
|
||||
return this.defaultDescription;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -50,9 +51,10 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
|||
final boolean liberal,
|
||||
final @NonNull String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
|
||||
@NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription description
|
||||
) {
|
||||
super(required, name, new BooleanParser<>(liberal), defaultValue, Boolean.class, suggestionsProvider);
|
||||
super(required, name, new BooleanParser<>(liberal), defaultValue, Boolean.class, suggestionsProvider, description);
|
||||
this.liberal = liberal;
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +112,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
|||
* @return Liberal boolean
|
||||
*/
|
||||
public boolean isLiberal() {
|
||||
return liberal;
|
||||
return this.liberal;
|
||||
}
|
||||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, Boolean> {
|
||||
|
|
@ -144,7 +146,8 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
|||
this.getName(),
|
||||
this.liberal,
|
||||
this.getDefaultValue(),
|
||||
this.getSuggestionsProvider()
|
||||
this.getSuggestionsProvider(),
|
||||
this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -49,9 +50,10 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
|||
final byte max,
|
||||
final @NonNull String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
|
||||
@NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new ByteParser<>(min, max), defaultValue, Byte.class, suggestionsProvider);
|
||||
super(required, name, new ByteParser<>(min, max), defaultValue, Byte.class, suggestionsProvider, defaultDescription);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
|
@ -161,7 +163,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
|||
@Override
|
||||
public @NonNull ByteArgument<C> build() {
|
||||
return new ByteArgument<>(this.isRequired(), this.getName(), this.min, this.max,
|
||||
this.getDefaultValue(), this.getSuggestionsProvider()
|
||||
this.getDefaultValue(), this.getSuggestionsProvider(), this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -46,9 +47,10 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
|
|||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>,
|
||||
@NonNull String, @NonNull List<@NonNull String>> suggestionsProvider
|
||||
) {
|
||||
super(required, name, new CharacterParser<>(), defaultValue, Character.class, suggestionsProvider);
|
||||
@NonNull String, @NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new CharacterParser<>(), defaultValue, Character.class, suggestionsProvider, defaultDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,7 +116,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
|
|||
@Override
|
||||
public @NonNull CharArgument<C> build() {
|
||||
return new CharArgument<>(this.isRequired(), this.getName(),
|
||||
this.getDefaultValue(), this.getSuggestionsProvider()
|
||||
this.getDefaultValue(), this.getSuggestionsProvider(), this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -49,9 +50,10 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
|||
final double max,
|
||||
final String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
|
||||
@NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new DoubleParser<>(min, max), defaultValue, Double.class, suggestionsProvider);
|
||||
super(required, name, new DoubleParser<>(min, max), defaultValue, Double.class, suggestionsProvider, defaultDescription);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
|
@ -161,7 +163,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
|||
@Override
|
||||
public @NonNull DoubleArgument<C> build() {
|
||||
return new DoubleArgument<>(this.isRequired(), this.getName(), this.min, this.max,
|
||||
this.getDefaultValue(), this.getSuggestionsProvider()
|
||||
this.getDefaultValue(), this.getSuggestionsProvider(), this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -55,9 +56,10 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
|
|||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
|
||||
@NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new EnumParser<>(enumClass), defaultValue, enumClass, suggestionsProvider);
|
||||
super(required, name, new EnumParser<>(enumClass), defaultValue, enumClass, suggestionsProvider, defaultDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -139,7 +141,7 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
|
|||
@Override
|
||||
public @NonNull CommandArgument<C, E> build() {
|
||||
return new EnumArgument<>(this.enumClass, this.isRequired(), this.getName(),
|
||||
this.getDefaultValue(), this.getSuggestionsProvider()
|
||||
this.getDefaultValue(), this.getSuggestionsProvider(), this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -49,9 +50,10 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
|||
final float max,
|
||||
final @NonNull String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>,
|
||||
@NonNull String, @NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull String, @NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new FloatParser<>(min, max), defaultValue, Float.class, suggestionsProvider);
|
||||
super(required, name, new FloatParser<>(min, max), defaultValue, Float.class, suggestionsProvider, defaultDescription);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
|
@ -161,7 +163,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
|||
@Override
|
||||
public @NonNull FloatArgument<C> build() {
|
||||
return new FloatArgument<>(this.isRequired(), this.getName(), this.min, this.max,
|
||||
this.getDefaultValue(), this.getSuggestionsProvider()
|
||||
this.getDefaultValue(), this.getSuggestionsProvider(), this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -56,9 +57,10 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
|||
final int max,
|
||||
final String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
|
||||
@NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new IntegerParser<>(min, max), defaultValue, Integer.class, suggestionsProvider);
|
||||
super(required, name, new IntegerParser<>(min, max), defaultValue, Integer.class, suggestionsProvider, defaultDescription);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
|
@ -168,7 +170,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
|||
@Override
|
||||
public @NonNull IntegerArgument<C> build() {
|
||||
return new IntegerArgument<>(this.isRequired(), this.getName(), this.min, this.max,
|
||||
this.getDefaultValue(), this.getSuggestionsProvider()
|
||||
this.getDefaultValue(), this.getSuggestionsProvider(), this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -49,9 +50,10 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
|||
final long max,
|
||||
final String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
|
||||
@NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new LongParser<>(min, max), defaultValue, Long.class, suggestionsProvider);
|
||||
super(required, name, new LongParser<>(min, max), defaultValue, Long.class, suggestionsProvider, defaultDescription);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
|
@ -161,7 +163,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
|||
@Override
|
||||
public @NonNull LongArgument<C> build() {
|
||||
return new LongArgument<>(this.isRequired(), this.getName(), this.min,
|
||||
this.max, this.getDefaultValue(), this.getSuggestionsProvider()
|
||||
this.max, this.getDefaultValue(), this.getSuggestionsProvider(), this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -49,9 +50,10 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
|||
final short max,
|
||||
final String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
|
||||
@NonNull List<String>> suggestionsProvider
|
||||
@NonNull List<String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new ShortParser<>(min, max), defaultValue, Short.class, suggestionsProvider);
|
||||
super(required, name, new ShortParser<>(min, max), defaultValue, Short.class, suggestionsProvider, defaultDescription);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
|
@ -161,7 +163,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
|||
@Override
|
||||
public @NonNull ShortArgument<C> build() {
|
||||
return new ShortArgument<>(this.isRequired(), this.getName(), this.min, this.max,
|
||||
this.getDefaultValue(), this.getSuggestionsProvider()
|
||||
this.getDefaultValue(), this.getSuggestionsProvider(), this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -56,10 +57,11 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
|||
final @NonNull StringMode stringMode,
|
||||
final @NonNull String defaultValue,
|
||||
final @NonNull BiFunction<@NonNull CommandContext<C>, @NonNull String,
|
||||
@NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new StringParser<>(stringMode, suggestionsProvider),
|
||||
defaultValue, String.class, suggestionsProvider
|
||||
defaultValue, String.class, suggestionsProvider, defaultDescription
|
||||
);
|
||||
this.stringMode = stringMode;
|
||||
}
|
||||
|
|
@ -265,7 +267,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
|||
@Override
|
||||
public @NonNull StringArgument<C> build() {
|
||||
return new StringArgument<>(this.isRequired(), this.getName(), this.stringMode,
|
||||
this.getDefaultValue(), this.suggestionsProvider
|
||||
this.getDefaultValue(), this.suggestionsProvider, this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -47,7 +48,8 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
|||
private StringArrayArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider
|
||||
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(
|
||||
required,
|
||||
|
|
@ -55,7 +57,8 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
|||
new StringArrayParser<>(),
|
||||
"",
|
||||
TypeToken.get(String[].class),
|
||||
suggestionsProvider
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +77,8 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
|||
return new StringArrayArgument<>(
|
||||
true,
|
||||
name,
|
||||
suggestionsProvider
|
||||
suggestionsProvider,
|
||||
ArgumentDescription.empty()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +97,8 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
|||
return new StringArrayArgument<>(
|
||||
false,
|
||||
name,
|
||||
suggestionsProvider
|
||||
suggestionsProvider,
|
||||
ArgumentDescription.empty()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.standard;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
|
|
@ -47,9 +48,10 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
|
|||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
final @Nullable BiFunction<@NonNull CommandContext<C>,
|
||||
@NonNull String, @NonNull List<@NonNull String>> suggestionsProvider
|
||||
@NonNull String, @NonNull List<@NonNull String>> suggestionsProvider,
|
||||
final @NonNull ArgumentDescription defaultDescription
|
||||
) {
|
||||
super(required, name, new UUIDParser<>(), defaultValue, UUID.class, suggestionsProvider);
|
||||
super(required, name, new UUIDParser<>(), defaultValue, UUID.class, suggestionsProvider, defaultDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,7 +116,13 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
|
|||
*/
|
||||
@Override
|
||||
public @NonNull UUIDArgument<C> build() {
|
||||
return new UUIDArgument<>(this.isRequired(), this.getName(), this.getDefaultValue(), this.getSuggestionsProvider());
|
||||
return new UUIDArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
this.getSuggestionsProvider(),
|
||||
this.getDefaultDescription()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue