chore(core): add apiguardian @API annotations (#368)
This commit is contained in:
parent
d4ab593460
commit
4360847852
119 changed files with 531 additions and 17 deletions
|
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Core: Add delegating command execution handlers ([#363](https://github.com/Incendo/cloud/pull/363))
|
- Core: Add delegating command execution handlers ([#363](https://github.com/Incendo/cloud/pull/363))
|
||||||
- Core: Add `builder()` getter to `Command.Builder` ([#363](https://github.com/Incendo/cloud/pull/363))
|
- Core: Add `builder()` getter to `Command.Builder` ([#363](https://github.com/Incendo/cloud/pull/363))
|
||||||
- Core: Add flag yielding modes to `StringArgument` and `StringArrayArgument` ([#367](https://github.com/Incendo/cloud/pull/367))
|
- Core: Add flag yielding modes to `StringArgument` and `StringArrayArgument` ([#367](https://github.com/Incendo/cloud/pull/367))
|
||||||
|
- Core: Add [apiguardian](https://github.com/apiguardian-team/apiguardian) `@API` annotations ([#368](https://github.com/Incendo/cloud/pull/368))
|
||||||
- Annotations: Annotation string processors ([#353](https://github.com/Incendo/cloud/pull/353))
|
- Annotations: Annotation string processors ([#353](https://github.com/Incendo/cloud/pull/353))
|
||||||
- Annotations: `@CommandContainer` annotation processing ([#364](https://github.com/Incendo/cloud/pull/364))
|
- Annotations: `@CommandContainer` annotation processing ([#364](https://github.com/Incendo/cloud/pull/364))
|
||||||
- Annotations: `@CommandMethod` annotation processing for compile-time validation ([#365](https://github.com/Incendo/cloud/pull/365))
|
- Annotations: `@CommandMethod` annotation processing for compile-time validation ([#365](https://github.com/Incendo/cloud/pull/365))
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,8 @@ repositories {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnlyApi(libs.checkerQual)
|
compileOnlyApi(libs.checkerQual)
|
||||||
|
compileOnlyApi(libs.apiguardian)
|
||||||
|
|
||||||
testImplementation(libs.jupiterEngine)
|
testImplementation(libs.jupiterEngine)
|
||||||
testImplementation(libs.jupiterParams)
|
testImplementation(libs.jupiterParams)
|
||||||
testImplementation(libs.mockitoCore)
|
testImplementation(libs.mockitoCore)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework;
|
package cloud.commandframework;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
@ -33,6 +34,7 @@ import static java.util.Objects.requireNonNull;
|
||||||
*
|
*
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public interface ArgumentDescription {
|
public interface ArgumentDescription {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import java.util.Optional;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -56,6 +57,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class Command<C> {
|
public class Command<C> {
|
||||||
|
|
||||||
private final List<@NonNull CommandComponent<C>> components;
|
private final List<@NonNull CommandComponent<C>> components;
|
||||||
|
|
@ -75,6 +77,7 @@ public class Command<C> {
|
||||||
* @param commandMeta Command meta instance
|
* @param commandMeta Command meta instance
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public Command(
|
public Command(
|
||||||
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
|
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
|
||||||
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
||||||
|
|
@ -118,6 +121,7 @@ public class Command<C> {
|
||||||
* @param commandMeta Command meta instance
|
* @param commandMeta Command meta instance
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public Command(
|
public Command(
|
||||||
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
|
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
|
||||||
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
||||||
|
|
@ -136,6 +140,7 @@ public class Command<C> {
|
||||||
* @param commandMeta Command meta instance
|
* @param commandMeta Command meta instance
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public Command(
|
public Command(
|
||||||
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
|
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
|
||||||
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
||||||
|
|
@ -157,6 +162,7 @@ public class Command<C> {
|
||||||
* @see #Command(List, CommandExecutionHandler, Class, CommandPermission, CommandMeta)
|
* @see #Command(List, CommandExecutionHandler, Class, CommandPermission, CommandMeta)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED)
|
||||||
public Command(
|
public Command(
|
||||||
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
|
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
|
||||||
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
||||||
|
|
@ -178,6 +184,7 @@ public class Command<C> {
|
||||||
* @see #Command(List, CommandExecutionHandler, Class, CommandMeta)
|
* @see #Command(List, CommandExecutionHandler, Class, CommandMeta)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED)
|
||||||
public Command(
|
public Command(
|
||||||
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
|
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
|
||||||
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
||||||
|
|
@ -198,6 +205,7 @@ public class Command<C> {
|
||||||
* @see #Command(List, CommandExecutionHandler, CommandPermission, CommandMeta)
|
* @see #Command(List, CommandExecutionHandler, CommandPermission, CommandMeta)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED)
|
||||||
public Command(
|
public Command(
|
||||||
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
|
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
|
||||||
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
|
||||||
|
|
@ -231,6 +239,7 @@ public class Command<C> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #newBuilder(String, CommandMeta, ArgumentDescription, String...)} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #newBuilder(String, CommandMeta, ArgumentDescription, String...)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public static <C> @NonNull Builder<C> newBuilder(
|
public static <C> @NonNull Builder<C> newBuilder(
|
||||||
final @NonNull String commandName,
|
final @NonNull String commandName,
|
||||||
final @NonNull CommandMeta commandMeta,
|
final @NonNull CommandMeta commandMeta,
|
||||||
|
|
@ -252,6 +261,7 @@ public class Command<C> {
|
||||||
* @return Command builder
|
* @return Command builder
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public static <C> @NonNull Builder<C> newBuilder(
|
public static <C> @NonNull Builder<C> newBuilder(
|
||||||
final @NonNull String commandName,
|
final @NonNull String commandName,
|
||||||
final @NonNull CommandMeta commandMeta,
|
final @NonNull CommandMeta commandMeta,
|
||||||
|
|
@ -314,6 +324,7 @@ public class Command<C> {
|
||||||
* @return Copy of the command component array. This List is mutable
|
* @return Copy of the command component array. This List is mutable
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public @NonNull List<CommandComponent<@NonNull C>> getComponents() {
|
public @NonNull List<CommandComponent<@NonNull C>> getComponents() {
|
||||||
return new ArrayList<>(this.components);
|
return new ArrayList<>(this.components);
|
||||||
}
|
}
|
||||||
|
|
@ -364,6 +375,7 @@ public class Command<C> {
|
||||||
* Use {@link #getArguments()} and search in that, instead.
|
* Use {@link #getArguments()} and search in that, instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED)
|
||||||
public @NonNull String getArgumentDescription(final @NonNull CommandArgument<C, ?> argument) {
|
public @NonNull String getArgumentDescription(final @NonNull CommandArgument<C, ?> argument) {
|
||||||
for (final CommandComponent<C> component : this.components) {
|
for (final CommandComponent<C> component : this.components) {
|
||||||
if (component.getArgument().equals(argument)) {
|
if (component.getArgument().equals(argument)) {
|
||||||
|
|
@ -384,7 +396,7 @@ public class Command<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether or not the command is hidden
|
* Check whether the command is hidden
|
||||||
*
|
*
|
||||||
* @return {@code true} if the command is hidden, {@code false} if not
|
* @return {@code true} if the command is hidden, {@code false} if not
|
||||||
*/
|
*/
|
||||||
|
|
@ -399,6 +411,7 @@ public class Command<C> {
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> {
|
public static final class Builder<C> {
|
||||||
|
|
||||||
private final CommandMeta commandMeta;
|
private final CommandMeta commandMeta;
|
||||||
|
|
@ -435,6 +448,7 @@ public class Command<C> {
|
||||||
* @return required sender type
|
* @return required sender type
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public @Nullable Class<? extends C> senderType() {
|
public @Nullable Class<? extends C> senderType() {
|
||||||
return this.senderType;
|
return this.senderType;
|
||||||
}
|
}
|
||||||
|
|
@ -447,6 +461,7 @@ public class Command<C> {
|
||||||
* @return required permission
|
* @return required permission
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public @NonNull CommandPermission commandPermission() {
|
public @NonNull CommandPermission commandPermission() {
|
||||||
return this.commandPermission;
|
return this.commandPermission;
|
||||||
}
|
}
|
||||||
|
|
@ -460,6 +475,7 @@ public class Command<C> {
|
||||||
* @deprecated for removal since 1.2.0, use the typesafe variant at {@link #meta(CommandMeta.Key, Object)} instead.
|
* @deprecated for removal since 1.2.0, use the typesafe variant at {@link #meta(CommandMeta.Key, Object)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.2.0")
|
||||||
public @NonNull Builder<C> meta(final @NonNull String key, final @NonNull String value) {
|
public @NonNull Builder<C> meta(final @NonNull String key, final @NonNull String value) {
|
||||||
final CommandMeta commandMeta = SimpleCommandMeta.builder().with(this.commandMeta).with(key, value).build();
|
final CommandMeta commandMeta = SimpleCommandMeta.builder().with(this.commandMeta).with(key, value).build();
|
||||||
return new Builder<>(
|
return new Builder<>(
|
||||||
|
|
@ -482,6 +498,7 @@ public class Command<C> {
|
||||||
* @return New builder instance using the inserted meta key-value pair
|
* @return New builder instance using the inserted meta key-value pair
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public <V> @NonNull Builder<C> meta(final CommandMeta.@NonNull Key<V> key, final @NonNull V value) {
|
public <V> @NonNull Builder<C> meta(final CommandMeta.@NonNull Key<V> key, final @NonNull V value) {
|
||||||
final CommandMeta commandMeta = SimpleCommandMeta.builder().with(this.commandMeta).with(key, value).build();
|
final CommandMeta commandMeta = SimpleCommandMeta.builder().with(this.commandMeta).with(key, value).build();
|
||||||
return new Builder<>(
|
return new Builder<>(
|
||||||
|
|
@ -539,6 +556,7 @@ public class Command<C> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #literal(String, ArgumentDescription, String...)} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #literal(String, ArgumentDescription, String...)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public @NonNull Builder<C> literal(
|
public @NonNull Builder<C> literal(
|
||||||
final @NonNull String main,
|
final @NonNull String main,
|
||||||
final @NonNull Description description,
|
final @NonNull Description description,
|
||||||
|
|
@ -556,6 +574,7 @@ public class Command<C> {
|
||||||
* @return New builder instance with the modified command chain
|
* @return New builder instance with the modified command chain
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public @NonNull Builder<C> literal(
|
public @NonNull Builder<C> literal(
|
||||||
final @NonNull String main,
|
final @NonNull String main,
|
||||||
final @NonNull ArgumentDescription description,
|
final @NonNull ArgumentDescription description,
|
||||||
|
|
@ -597,6 +616,7 @@ public class Command<C> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #argument(CommandArgument, ArgumentDescription)} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #argument(CommandArgument, ArgumentDescription)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public <T> @NonNull Builder<C> argument(
|
public <T> @NonNull Builder<C> argument(
|
||||||
final @NonNull CommandArgument<C, T> argument,
|
final @NonNull CommandArgument<C, T> argument,
|
||||||
final @NonNull Description description
|
final @NonNull Description description
|
||||||
|
|
@ -613,6 +633,7 @@ public class Command<C> {
|
||||||
* @return New builder instance with the command argument inserted into the argument list
|
* @return New builder instance with the command argument inserted into the argument list
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @NonNull Builder<C> argument(
|
public <T> @NonNull Builder<C> argument(
|
||||||
final @NonNull CommandArgument<C, T> argument,
|
final @NonNull CommandArgument<C, T> argument,
|
||||||
final @NonNull ArgumentDescription description
|
final @NonNull ArgumentDescription description
|
||||||
|
|
@ -646,6 +667,7 @@ public class Command<C> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #argument(CommandArgument.Builder, ArgumentDescription)} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #argument(CommandArgument.Builder, ArgumentDescription)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public <T> @NonNull Builder<C> argument(
|
public <T> @NonNull Builder<C> argument(
|
||||||
final CommandArgument.@NonNull Builder<C, T> builder,
|
final CommandArgument.@NonNull Builder<C, T> builder,
|
||||||
final @NonNull Description description
|
final @NonNull Description description
|
||||||
|
|
@ -663,6 +685,7 @@ public class Command<C> {
|
||||||
* @return New builder instance with the command argument inserted into the argument list
|
* @return New builder instance with the command argument inserted into the argument list
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @NonNull Builder<C> argument(
|
public <T> @NonNull Builder<C> argument(
|
||||||
final CommandArgument.@NonNull Builder<C, T> builder,
|
final CommandArgument.@NonNull Builder<C, T> builder,
|
||||||
final @NonNull ArgumentDescription description
|
final @NonNull ArgumentDescription description
|
||||||
|
|
@ -723,6 +746,7 @@ public class Command<C> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #argumentPair(String, Pair, Pair, ArgumentDescription)} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #argumentPair(String, Pair, Pair, ArgumentDescription)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public <U, V> @NonNull Builder<C> argumentPair(
|
public <U, V> @NonNull Builder<C> argumentPair(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull Pair<@NonNull String, @NonNull String> names,
|
final @NonNull Pair<@NonNull String, @NonNull String> names,
|
||||||
|
|
@ -750,6 +774,7 @@ public class Command<C> {
|
||||||
* @return Builder instance with the argument inserted
|
* @return Builder instance with the argument inserted
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <U, V> @NonNull Builder<C> argumentPair(
|
public <U, V> @NonNull Builder<C> argumentPair(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull Pair<@NonNull String, @NonNull String> names,
|
final @NonNull Pair<@NonNull String, @NonNull String> names,
|
||||||
|
|
@ -785,6 +810,7 @@ public class Command<C> {
|
||||||
* {@link #argumentPair(String, TypeToken, Pair, Pair, BiFunction, ArgumentDescription)} instead.
|
* {@link #argumentPair(String, TypeToken, Pair, Pair, BiFunction, ArgumentDescription)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public <U, V, O> @NonNull Builder<C> argumentPair(
|
public <U, V, O> @NonNull Builder<C> argumentPair(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull TypeToken<O> outputType,
|
final @NonNull TypeToken<O> outputType,
|
||||||
|
|
@ -817,6 +843,7 @@ public class Command<C> {
|
||||||
* @return Builder instance with the argument inserted
|
* @return Builder instance with the argument inserted
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <U, V, O> @NonNull Builder<C> argumentPair(
|
public <U, V, O> @NonNull Builder<C> argumentPair(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull TypeToken<O> outputType,
|
final @NonNull TypeToken<O> outputType,
|
||||||
|
|
@ -855,6 +882,7 @@ public class Command<C> {
|
||||||
* instead.
|
* instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public <U, V, W> @NonNull Builder<C> argumentTriplet(
|
public <U, V, W> @NonNull Builder<C> argumentTriplet(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull Triplet<String, String, String> names,
|
final @NonNull Triplet<String, String, String> names,
|
||||||
|
|
@ -883,6 +911,7 @@ public class Command<C> {
|
||||||
* @return Builder instance with the argument inserted
|
* @return Builder instance with the argument inserted
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <U, V, W> @NonNull Builder<C> argumentTriplet(
|
public <U, V, W> @NonNull Builder<C> argumentTriplet(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull Triplet<String, String, String> names,
|
final @NonNull Triplet<String, String, String> names,
|
||||||
|
|
@ -919,6 +948,7 @@ public class Command<C> {
|
||||||
* {@link #argumentTriplet(String, TypeToken, Triplet, Triplet, BiFunction, ArgumentDescription)} instead.
|
* {@link #argumentTriplet(String, TypeToken, Triplet, Triplet, BiFunction, ArgumentDescription)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public <U, V, W, O> @NonNull Builder<C> argumentTriplet(
|
public <U, V, W, O> @NonNull Builder<C> argumentTriplet(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull TypeToken<O> outputType,
|
final @NonNull TypeToken<O> outputType,
|
||||||
|
|
@ -959,6 +989,7 @@ public class Command<C> {
|
||||||
* @return Builder instance with the argument inserted
|
* @return Builder instance with the argument inserted
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <U, V, W, O> @NonNull Builder<C> argumentTriplet(
|
public <U, V, W, O> @NonNull Builder<C> argumentTriplet(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull TypeToken<O> outputType,
|
final @NonNull TypeToken<O> outputType,
|
||||||
|
|
@ -1002,6 +1033,7 @@ public class Command<C> {
|
||||||
* @return the current handler
|
* @return the current handler
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public @NonNull CommandExecutionHandler<C> handler() {
|
public @NonNull CommandExecutionHandler<C> handler() {
|
||||||
return this.commandExecutionHandler;
|
return this.commandExecutionHandler;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public final class CommandComponent<C> {
|
public final class CommandComponent<C> {
|
||||||
|
|
||||||
private final CommandArgument<C, ?> argument;
|
private final CommandArgument<C, ?> argument;
|
||||||
|
|
@ -68,6 +70,7 @@ public final class CommandComponent<C> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #getArgumentDescription()} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #getArgumentDescription()} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public @NonNull Description getDescription() {
|
public @NonNull Description getDescription() {
|
||||||
if (this.description instanceof Description) {
|
if (this.description instanceof Description) {
|
||||||
return (Description) this.description;
|
return (Description) this.description;
|
||||||
|
|
@ -82,6 +85,7 @@ public final class CommandComponent<C> {
|
||||||
* @return command component description
|
* @return command component description
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public @NonNull ArgumentDescription getArgumentDescription() {
|
public @NonNull ArgumentDescription getArgumentDescription() {
|
||||||
return this.description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
@ -120,6 +124,7 @@ public final class CommandComponent<C> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #of(CommandArgument, ArgumentDescription)} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #of(CommandArgument, ArgumentDescription)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public static <C> @NonNull CommandComponent<C> of(
|
public static <C> @NonNull CommandComponent<C> of(
|
||||||
final @NonNull CommandArgument<C, ?> commandArgument,
|
final @NonNull CommandArgument<C, ?> commandArgument,
|
||||||
final @NonNull Description commandDescription
|
final @NonNull Description commandDescription
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,11 @@ import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class CommandHelpHandler<C> {
|
public final class CommandHelpHandler<C> {
|
||||||
|
|
||||||
private final CommandManager<C> commandManager;
|
private final CommandManager<C> commandManager;
|
||||||
|
|
@ -289,6 +291,7 @@ public final class CommandHelpHandler<C> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Something that can be returned as the result of a help query
|
* Something that can be returned as the result of a help query
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -301,10 +304,13 @@ public final class CommandHelpHandler<C> {
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface HelpTopic<C> {
|
public interface HelpTopic<C> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class VerboseHelpEntry<C> {
|
public static final class VerboseHelpEntry<C> {
|
||||||
|
|
||||||
private final Command<C> command;
|
private final Command<C> command;
|
||||||
|
|
@ -378,11 +384,13 @@ public final class CommandHelpHandler<C> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of available commands
|
* Index of available commands
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class IndexHelpTopic<C> implements HelpTopic<C> {
|
public static final class IndexHelpTopic<C> implements HelpTopic<C> {
|
||||||
|
|
||||||
private final List<VerboseHelpEntry<C>> entries;
|
private final List<VerboseHelpEntry<C>> entries;
|
||||||
|
|
@ -441,6 +449,7 @@ public final class CommandHelpHandler<C> {
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class VerboseHelpTopic<C> implements HelpTopic<C> {
|
public static final class VerboseHelpTopic<C> implements HelpTopic<C> {
|
||||||
|
|
||||||
private final Command<C> command;
|
private final Command<C> command;
|
||||||
|
|
@ -503,6 +512,7 @@ public final class CommandHelpHandler<C> {
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class MultiHelpTopic<C> implements HelpTopic<C> {
|
public static final class MultiHelpTopic<C> implements HelpTopic<C> {
|
||||||
|
|
||||||
private final String longestPath;
|
private final String longestPath;
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
@ -84,6 +85,7 @@ import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public abstract class CommandManager<C> {
|
public abstract class CommandManager<C> {
|
||||||
|
|
||||||
private final Map<Class<? extends Exception>, BiConsumer<C, ? extends Exception>> exceptionHandlers = new HashMap<>();
|
private final Map<Class<? extends Exception>, BiConsumer<C, ? extends Exception>> exceptionHandlers = new HashMap<>();
|
||||||
|
|
@ -250,6 +252,7 @@ public abstract class CommandManager<C> {
|
||||||
* @return the caption variable replacement handler
|
* @return the caption variable replacement handler
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public @NonNull CaptionVariableReplacementHandler captionVariableReplacementHandler() {
|
public @NonNull CaptionVariableReplacementHandler captionVariableReplacementHandler() {
|
||||||
return this.captionVariableReplacementHandler;
|
return this.captionVariableReplacementHandler;
|
||||||
}
|
}
|
||||||
|
|
@ -260,6 +263,7 @@ public abstract class CommandManager<C> {
|
||||||
* @param captionVariableReplacementHandler new replacement handler
|
* @param captionVariableReplacementHandler new replacement handler
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public void captionVariableReplacementHandler(
|
public void captionVariableReplacementHandler(
|
||||||
final @NonNull CaptionVariableReplacementHandler captionVariableReplacementHandler
|
final @NonNull CaptionVariableReplacementHandler captionVariableReplacementHandler
|
||||||
) {
|
) {
|
||||||
|
|
@ -363,6 +367,7 @@ public abstract class CommandManager<C> {
|
||||||
* @deprecated Use {@link #setCaptionRegistry(CaptionRegistry)} These methods are identical.
|
* @deprecated Use {@link #setCaptionRegistry(CaptionRegistry)} These methods are identical.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED)
|
||||||
public final void registerDefaultCaptions(final @NonNull CaptionRegistry<C> captionRegistry) {
|
public final void registerDefaultCaptions(final @NonNull CaptionRegistry<C> captionRegistry) {
|
||||||
this.captionRegistry = captionRegistry;
|
this.captionRegistry = captionRegistry;
|
||||||
}
|
}
|
||||||
|
|
@ -392,9 +397,11 @@ public abstract class CommandManager<C> {
|
||||||
* @param description Description for the root literal
|
* @param description Description for the root literal
|
||||||
* @param meta Command meta
|
* @param meta Command meta
|
||||||
* @return Builder instance
|
* @return Builder instance
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #commandBuilder(String, Collection, Description, CommandMeta)} instead.
|
* @deprecated for removal since 1.4.0. Use
|
||||||
|
* {@link #commandBuilder(String, Collection, ArgumentDescription, CommandMeta)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public Command.@NonNull Builder<C> commandBuilder(
|
public Command.@NonNull Builder<C> commandBuilder(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull Collection<String> aliases,
|
final @NonNull Collection<String> aliases,
|
||||||
|
|
@ -421,6 +428,7 @@ public abstract class CommandManager<C> {
|
||||||
* @return Builder instance
|
* @return Builder instance
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public Command.@NonNull Builder<C> commandBuilder(
|
public Command.@NonNull Builder<C> commandBuilder(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull Collection<String> aliases,
|
final @NonNull Collection<String> aliases,
|
||||||
|
|
@ -484,6 +492,7 @@ public abstract class CommandManager<C> {
|
||||||
* instead.
|
* instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public Command.@NonNull Builder<C> commandBuilder(
|
public Command.@NonNull Builder<C> commandBuilder(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull CommandMeta meta,
|
final @NonNull CommandMeta meta,
|
||||||
|
|
@ -510,6 +519,7 @@ public abstract class CommandManager<C> {
|
||||||
* @return Builder instance
|
* @return Builder instance
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public Command.@NonNull Builder<C> commandBuilder(
|
public Command.@NonNull Builder<C> commandBuilder(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull CommandMeta meta,
|
final @NonNull CommandMeta meta,
|
||||||
|
|
@ -575,6 +585,7 @@ public abstract class CommandManager<C> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #commandBuilder(String, ArgumentDescription, String...)} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #commandBuilder(String, ArgumentDescription, String...)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public Command.@NonNull Builder<C> commandBuilder(
|
public Command.@NonNull Builder<C> commandBuilder(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull Description description,
|
final @NonNull Description description,
|
||||||
|
|
@ -603,6 +614,7 @@ public abstract class CommandManager<C> {
|
||||||
* @see #createDefaultCommandMeta() Default command meta creation
|
* @see #createDefaultCommandMeta() Default command meta creation
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public Command.@NonNull Builder<C> commandBuilder(
|
public Command.@NonNull Builder<C> commandBuilder(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final @NonNull ArgumentDescription description,
|
final @NonNull ArgumentDescription description,
|
||||||
|
|
@ -943,6 +955,7 @@ public abstract class CommandManager<C> {
|
||||||
* @return Command execution coordinator
|
* @return Command execution coordinator
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
public @NonNull CommandExecutionCoordinator<C> commandExecutionCoordinator() {
|
public @NonNull CommandExecutionCoordinator<C> commandExecutionCoordinator() {
|
||||||
return this.commandExecutionCoordinator;
|
return this.commandExecutionCoordinator;
|
||||||
}
|
}
|
||||||
|
|
@ -955,6 +968,7 @@ public abstract class CommandManager<C> {
|
||||||
* @throws IllegalStateException if the manager is in any state but {@code in} or {@code out}
|
* @throws IllegalStateException if the manager is in any state but {@code in} or {@code out}
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
protected final void transitionOrThrow(final @NonNull RegistrationState in, final @NonNull RegistrationState out) {
|
protected final void transitionOrThrow(final @NonNull RegistrationState in, final @NonNull RegistrationState out) {
|
||||||
if (!this.transitionIfPossible(in, out)) {
|
if (!this.transitionIfPossible(in, out)) {
|
||||||
throw new IllegalStateException("Command manager was in state " + this.state.get() + ", while we were expecting a state "
|
throw new IllegalStateException("Command manager was in state " + this.state.get() + ", while we were expecting a state "
|
||||||
|
|
@ -970,6 +984,7 @@ public abstract class CommandManager<C> {
|
||||||
* @return {@code true} if the state transition was successful, or the manager was already in the desired state
|
* @return {@code true} if the state transition was successful, or the manager was already in the desired state
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
protected final boolean transitionIfPossible(final @NonNull RegistrationState in, final @NonNull RegistrationState out) {
|
protected final boolean transitionIfPossible(final @NonNull RegistrationState in, final @NonNull RegistrationState out) {
|
||||||
return this.state.compareAndSet(in, out) || this.state.get() == out;
|
return this.state.compareAndSet(in, out) || this.state.get() == out;
|
||||||
}
|
}
|
||||||
|
|
@ -981,6 +996,7 @@ public abstract class CommandManager<C> {
|
||||||
* @throws IllegalStateException if the manager is not in the expected state
|
* @throws IllegalStateException if the manager is not in the expected state
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
protected final void requireState(final @NonNull RegistrationState expected) {
|
protected final void requireState(final @NonNull RegistrationState expected) {
|
||||||
if (this.state.get() != expected) {
|
if (this.state.get() != expected) {
|
||||||
throw new IllegalStateException("This operation required the commands manager to be in state " + expected + ", but it "
|
throw new IllegalStateException("This operation required the commands manager to be in state " + expected + ", but it "
|
||||||
|
|
@ -995,6 +1011,7 @@ public abstract class CommandManager<C> {
|
||||||
* @throws IllegalStateException if the manager is not in the expected state
|
* @throws IllegalStateException if the manager is not in the expected state
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
protected final void lockRegistration() {
|
protected final void lockRegistration() {
|
||||||
if (this.getRegistrationState() == RegistrationState.BEFORE_REGISTRATION) {
|
if (this.getRegistrationState() == RegistrationState.BEFORE_REGISTRATION) {
|
||||||
this.transitionOrThrow(RegistrationState.BEFORE_REGISTRATION, RegistrationState.AFTER_REGISTRATION);
|
this.transitionOrThrow(RegistrationState.BEFORE_REGISTRATION, RegistrationState.AFTER_REGISTRATION);
|
||||||
|
|
@ -1011,6 +1028,7 @@ public abstract class CommandManager<C> {
|
||||||
* @return The current state
|
* @return The current state
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public final @NonNull RegistrationState getRegistrationState() {
|
public final @NonNull RegistrationState getRegistrationState() {
|
||||||
return this.state.get();
|
return this.state.get();
|
||||||
}
|
}
|
||||||
|
|
@ -1024,16 +1042,19 @@ public abstract class CommandManager<C> {
|
||||||
* @return {@code true} if the registration is allowed, else {@code false}
|
* @return {@code true} if the registration is allowed, else {@code false}
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public boolean isCommandRegistrationAllowed() {
|
public boolean isCommandRegistrationAllowed() {
|
||||||
return this.getSetting(ManagerSettings.ALLOW_UNSAFE_REGISTRATION) || this.state.get() != RegistrationState.AFTER_REGISTRATION;
|
return this.getSetting(ManagerSettings.ALLOW_UNSAFE_REGISTRATION) || this.state.get() != RegistrationState.AFTER_REGISTRATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurable command related settings
|
* Configurable command related settings
|
||||||
*
|
*
|
||||||
* @see CommandManager#setSetting(ManagerSettings, boolean) Set a manager setting
|
* @see CommandManager#setSetting(ManagerSettings, boolean) Set a manager setting
|
||||||
* @see CommandManager#getSetting(ManagerSettings) Get a manager setting
|
* @see CommandManager#getSetting(ManagerSettings) Get a manager setting
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public enum ManagerSettings {
|
public enum ManagerSettings {
|
||||||
/**
|
/**
|
||||||
* Do not create a compound permission and do not look greedily
|
* Do not create a compound permission and do not look greedily
|
||||||
|
|
@ -1057,6 +1078,7 @@ public abstract class CommandManager<C> {
|
||||||
*
|
*
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
ALLOW_UNSAFE_REGISTRATION,
|
ALLOW_UNSAFE_REGISTRATION,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1064,14 +1086,17 @@ public abstract class CommandManager<C> {
|
||||||
*
|
*
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
OVERRIDE_EXISTING_COMMANDS
|
OVERRIDE_EXISTING_COMMANDS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The point in the registration lifecycle for this commands manager
|
* The point in the registration lifecycle for this commands manager
|
||||||
*
|
*
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public enum RegistrationState {
|
public enum RegistrationState {
|
||||||
/**
|
/**
|
||||||
* The point when no commands have been registered yet.
|
* The point when no commands have been registered yet.
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -90,6 +91,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public final class CommandTree<C> {
|
public final class CommandTree<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework;
|
package cloud.commandframework;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @deprecated to become package-private since 1.4.0. Use {@link ArgumentDescription} instead.
|
* @deprecated to become package-private since 1.4.0. Use {@link ArgumentDescription} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public final class Description implements ArgumentDescription {
|
public final class Description implements ArgumentDescription {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
|
||||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||||
import cloud.commandframework.internal.CommandRegistrationHandler;
|
import cloud.commandframework.internal.CommandRegistrationHandler;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @deprecated Use a normal {@link CommandManager}'s registration state instead
|
* @deprecated Use a normal {@link CommandManager}'s registration state instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.2.0")
|
||||||
public abstract class LockableCommandManager<C> extends CommandManager<C> {
|
public abstract class LockableCommandManager<C> extends CommandManager<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,11 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
final class AnnotatedElementAccessor implements AnnotationAccessor {
|
final class AnnotatedElementAccessor implements AnnotationAccessor {
|
||||||
|
|
||||||
private final AnnotatedElement element;
|
private final AnnotatedElement element;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.AnnotatedElement;
|
import java.lang.reflect.AnnotatedElement;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -35,6 +36,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
*
|
*
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public interface AnnotationAccessor {
|
public interface AnnotationAccessor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,6 +45,7 @@ public interface AnnotationAccessor {
|
||||||
* @return Empty annotation accessor
|
* @return Empty annotation accessor
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
static @NonNull AnnotationAccessor empty() {
|
static @NonNull AnnotationAccessor empty() {
|
||||||
return new NullAnnotationAccessor();
|
return new NullAnnotationAccessor();
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +70,7 @@ public interface AnnotationAccessor {
|
||||||
* @return Annotation accessor that delegates to the given accessors (using their natural ordering)
|
* @return Annotation accessor that delegates to the given accessors (using their natural ordering)
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
static @NonNull AnnotationAccessor of(final @NonNull AnnotationAccessor@NonNull... accessors) {
|
static @NonNull AnnotationAccessor of(final @NonNull AnnotationAccessor@NonNull... accessors) {
|
||||||
return new MultiDelegateAnnotationAccessor(accessors);
|
return new MultiDelegateAnnotationAccessor(accessors);
|
||||||
}
|
}
|
||||||
|
|
@ -95,6 +99,7 @@ public interface AnnotationAccessor {
|
||||||
*
|
*
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*", since = "1.3.0")
|
||||||
final class NullAnnotationAccessor implements AnnotationAccessor {
|
final class NullAnnotationAccessor implements AnnotationAccessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,11 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
final class MultiDelegateAnnotationAccessor implements AnnotationAccessor {
|
final class MultiDelegateAnnotationAccessor implements AnnotationAccessor {
|
||||||
|
|
||||||
private final AnnotationAccessor[] accessors;
|
private final AnnotationAccessor[] accessors;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import cloud.commandframework.context.CommandContext;
|
||||||
import cloud.commandframework.types.tuples.Triplet;
|
import cloud.commandframework.types.tuples.Triplet;
|
||||||
import com.google.inject.ConfigurationException;
|
import com.google.inject.ConfigurationException;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -37,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public final class GuiceInjectionService<C> implements InjectionService<C> {
|
public final class GuiceInjectionService<C> implements InjectionService<C> {
|
||||||
|
|
||||||
private final Injector injector;
|
private final Injector injector;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.annotations.AnnotationAccessor;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import cloud.commandframework.services.types.Service;
|
import cloud.commandframework.services.types.Service;
|
||||||
import cloud.commandframework.types.tuples.Triplet;
|
import cloud.commandframework.types.tuples.Triplet;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that can be registered to the {@link ParameterInjectorRegistry} in order to provide
|
* Service that can be registered to the {@link ParameterInjectorRegistry} in order to provide
|
||||||
|
|
@ -37,6 +38,7 @@ import cloud.commandframework.types.tuples.Triplet;
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public interface InjectionService<C> extends
|
public interface InjectionService<C> extends
|
||||||
Service<Triplet<CommandContext<C>, Class<?>, AnnotationAccessor>, Object> {
|
Service<Triplet<CommandContext<C>, Class<?>, AnnotationAccessor>, Object> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.annotations.injection;
|
||||||
|
|
||||||
import cloud.commandframework.annotations.AnnotationAccessor;
|
import cloud.commandframework.annotations.AnnotationAccessor;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -37,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public interface ParameterInjector<C, T> {
|
public interface ParameterInjector<C, T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -46,6 +47,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
|
public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
|
||||||
|
|
||||||
private volatile int injectorCount = 0;
|
private volatile int injectorCount = 0;
|
||||||
|
|
@ -124,6 +126,7 @@ public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("EmptyCatch")
|
@SuppressWarnings("EmptyCatch")
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <@NonNull T> @NonNull Optional<T> getInjectable(
|
public <@NonNull T> @NonNull Optional<T> getInjectable(
|
||||||
final @NonNull Class<T> clazz,
|
final @NonNull Class<T> clazz,
|
||||||
final @NonNull CommandContext<C> context,
|
final @NonNull CommandContext<C> context,
|
||||||
|
|
@ -145,6 +148,7 @@ public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
|
||||||
* @param service Service implementation
|
* @param service Service implementation
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public void registerInjectionService(final InjectionService<C> service) {
|
public void registerInjectionService(final InjectionService<C> service) {
|
||||||
this.servicePipeline.registerServiceImplementation(new TypeToken<InjectionService<C>>() {
|
this.servicePipeline.registerServiceImplementation(new TypeToken<InjectionService<C>>() {
|
||||||
}, service, Collections.emptyList());
|
}, service, Collections.emptyList());
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,14 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command completions, separated by "," or ", "
|
* Command completions, separated by "," or ", "
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public @interface Completions {
|
public @interface Completions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that the argument should stop parsing when encountering what
|
* Indicates that the argument should stop parsing when encountering what
|
||||||
|
|
@ -38,6 +39,7 @@ import java.lang.annotation.Target;
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public @interface FlagYielding {
|
public @interface FlagYielding {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,14 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation used to make {@link cloud.commandframework.arguments.standard.StringArgument string arguments} greedy
|
* Annotation used to make {@link cloud.commandframework.arguments.standard.StringArgument string arguments} greedy
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public @interface Greedy {
|
public @interface Greedy {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation used to set the parsing mode of a {@link cloud.commandframework.arguments.standard.BooleanArgument boolean
|
* Annotation used to set the parsing mode of a {@link cloud.commandframework.arguments.standard.BooleanArgument boolean
|
||||||
|
|
@ -36,6 +37,7 @@ import java.lang.annotation.Target;
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
public @interface Liberal {
|
public @interface Liberal {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation used to set the parsing mode of a {@link cloud.commandframework.arguments.standard.StringArgument string
|
* Annotation used to set the parsing mode of a {@link cloud.commandframework.arguments.standard.StringArgument string
|
||||||
|
|
@ -36,6 +37,7 @@ import java.lang.annotation.Target;
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public @interface Quoted {
|
public @interface Quoted {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,6 +37,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public @interface Range {
|
public @interface Range {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
@ -53,6 +54,7 @@ import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
* @param <T> The type that the argument parses into
|
* @param <T> The type that the argument parses into
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>, CloudKeyHolder<T> {
|
public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>, CloudKeyHolder<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -126,6 +128,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
* @param argumentPreprocessors Argument preprocessors
|
* @param argumentPreprocessors Argument preprocessors
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public CommandArgument(
|
public CommandArgument(
|
||||||
final boolean required,
|
final boolean required,
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
|
|
@ -219,6 +222,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
* @param defaultDescription Default description to use when registering
|
* @param defaultDescription Default description to use when registering
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public CommandArgument(
|
public CommandArgument(
|
||||||
final boolean required,
|
final boolean required,
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
|
|
@ -265,6 +269,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
* @param defaultDescription Default description to use when registering
|
* @param defaultDescription Default description to use when registering
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public CommandArgument(
|
public CommandArgument(
|
||||||
final boolean required,
|
final boolean required,
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
|
|
@ -281,7 +286,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
/**
|
/**
|
||||||
* Construct a new command argument
|
* Construct a new command argument
|
||||||
*
|
*
|
||||||
* @param required Whether or not the argument is required
|
* @param required Whether the argument is required
|
||||||
* @param name The argument name
|
* @param name The argument name
|
||||||
* @param parser The argument parser
|
* @param parser The argument parser
|
||||||
* @param valueType Type produced by the parser
|
* @param valueType Type produced by the parser
|
||||||
|
|
@ -417,8 +422,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
*
|
*
|
||||||
* @return Owning command
|
* @return Owning command
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public @Nullable Command<C> getOwningCommand() {
|
||||||
public Command<C> getOwningCommand() {
|
|
||||||
return this.owningCommand;
|
return this.owningCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -537,7 +541,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether or not the argument has been used in a command
|
* Check whether the argument has been used in a command
|
||||||
*
|
*
|
||||||
* @return {@code true} if the argument has been used in a command, else {@code false}
|
* @return {@code true} if the argument has been used in a command, else {@code false}
|
||||||
*/
|
*/
|
||||||
|
|
@ -559,6 +563,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
* @param <T> Argument value type
|
* @param <T> Argument value type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static class Builder<C, T> {
|
public static class Builder<C, T> {
|
||||||
|
|
||||||
private final TypeToken<T> valueType;
|
private final TypeToken<T> valueType;
|
||||||
|
|
@ -679,6 +684,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
* @return Builder instance
|
* @return Builder instance
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public @NonNull @This Builder<@NonNull C, @NonNull T> withDefaultDescription(
|
public @NonNull @This Builder<@NonNull C, @NonNull T> withDefaultDescription(
|
||||||
final @NonNull ArgumentDescription defaultDescription
|
final @NonNull ArgumentDescription defaultDescription
|
||||||
) {
|
) {
|
||||||
|
|
@ -753,6 +759,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
|
||||||
* @param <B> the subclass type
|
* @param <B> the subclass type
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public abstract static class TypedBuilder<C, T, B extends Builder<C, T>> extends Builder<C, T> {
|
public abstract static class TypedBuilder<C, T, B extends Builder<C, T>> extends Builder<C, T> {
|
||||||
|
|
||||||
protected TypedBuilder(
|
protected TypedBuilder(
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.arguments;
|
||||||
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CommandSuggestionEngine<C> {
|
public interface CommandSuggestionEngine<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.arguments;
|
||||||
|
|
||||||
import cloud.commandframework.CommandTree;
|
import cloud.commandframework.CommandTree;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -34,6 +35,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CommandSyntaxFormatter<C> {
|
public interface CommandSyntaxFormatter<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import cloud.commandframework.services.State;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -39,6 +40,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public final class DelegatingCommandSuggestionEngine<C> implements CommandSuggestionEngine<C> {
|
public final class DelegatingCommandSuggestionEngine<C> implements CommandSuggestionEngine<C> {
|
||||||
|
|
||||||
private static final List<String> SINGLE_EMPTY_SUGGESTION = Collections.unmodifiableList(Collections.singletonList(""));
|
private static final List<String> SINGLE_EMPTY_SUGGESTION = Collections.unmodifiableList(Collections.singletonList(""));
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.arguments;
|
||||||
|
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
import cloud.commandframework.CommandTree;
|
import cloud.commandframework.CommandTree;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class DelegatingCommandSuggestionEngineFactory<C> {
|
public final class DelegatingCommandSuggestionEngineFactory<C> {
|
||||||
|
|
||||||
private final CommandManager<C> commandManager;
|
private final CommandManager<C> commandManager;
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
final class DelegatingSuggestionsProvider<C> implements BiFunction<@NonNull CommandContext<C>,
|
final class DelegatingSuggestionsProvider<C> implements BiFunction<@NonNull CommandContext<C>,
|
||||||
@NonNull String, @NonNull List<String>> {
|
@NonNull String, @NonNull List<String>> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.compound.FlagArgument;
|
||||||
import cloud.commandframework.arguments.flags.CommandFlag;
|
import cloud.commandframework.arguments.flags.CommandFlag;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -42,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public class StandardCommandSyntaxFormatter<C> implements CommandSyntaxFormatter<C> {
|
public class StandardCommandSyntaxFormatter<C> implements CommandSyntaxFormatter<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -132,6 +134,7 @@ public class StandardCommandSyntaxFormatter<C> implements CommandSyntaxFormatter
|
||||||
/**
|
/**
|
||||||
* Instance that is used when building command syntax
|
* Instance that is used when building command syntax
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static class FormattingInstance {
|
public static class FormattingInstance {
|
||||||
|
|
||||||
private final StringBuilder builder;
|
private final StringBuilder builder;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class StaticArgument<C> extends CommandArgument<C, String> {
|
public final class StaticArgument<C> extends CommandArgument<C, String> {
|
||||||
|
|
||||||
private StaticArgument(final boolean required, final @NonNull String name, final @NonNull String... aliases) {
|
private StaticArgument(final boolean required, final @NonNull String name, final @NonNull String... aliases) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import cloud.commandframework.arguments.parser.ParserRegistry;
|
||||||
import cloud.commandframework.types.tuples.Pair;
|
import cloud.commandframework.types.tuples.Pair;
|
||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,6 +41,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @param <V> Second argument type
|
* @param <V> Second argument type
|
||||||
* @param <O> Output type
|
* @param <O> Output type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class ArgumentPair<C, U, V, O> extends CompoundArgument<Pair<U, V>, C, O> {
|
public class ArgumentPair<C, U, V, O> extends CompoundArgument<Pair<U, V>, C, O> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -104,7 +106,9 @@ public class ArgumentPair<C, U, V, O> extends CompoundArgument<Pair<U, V>, C, O>
|
||||||
return new ArgumentPairIntermediaryBuilder<>(true, name, names, Pair.of(firstParser, secondaryParser), types);
|
return new ArgumentPairIntermediaryBuilder<>(true, name, names, Pair.of(firstParser, secondaryParser), types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class ArgumentPairIntermediaryBuilder<C, U, V> {
|
public static final class ArgumentPairIntermediaryBuilder<C, U, V> {
|
||||||
|
|
||||||
private final boolean required;
|
private final boolean required;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import cloud.commandframework.arguments.parser.ParserRegistry;
|
||||||
import cloud.commandframework.types.tuples.Triplet;
|
import cloud.commandframework.types.tuples.Triplet;
|
||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,6 +42,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @param <W> Third argument type
|
* @param <W> Third argument type
|
||||||
* @param <O> Output type
|
* @param <O> Output type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class ArgumentTriplet<C, U, V, W, O> extends CompoundArgument<Triplet<U, V, W>, C, O> {
|
public class ArgumentTriplet<C, U, V, W, O> extends CompoundArgument<Triplet<U, V, W>, C, O> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -115,7 +117,9 @@ public class ArgumentTriplet<C, U, V, W, O> extends CompoundArgument<Triplet<U,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class ArgumentTripletIntermediaryBuilder<C, U, V, W> {
|
public static final class ArgumentTripletIntermediaryBuilder<C, U, V, W> {
|
||||||
|
|
||||||
private final boolean required;
|
private final boolean required;
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
* @param <O> Output type
|
* @param <O> Output type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class CompoundArgument<T extends Tuple, C, O> extends CommandArgument<C, O> {
|
public class CompoundArgument<T extends Tuple, C, O> extends CommandArgument<C, O> {
|
||||||
|
|
||||||
private final Tuple types;
|
private final Tuple types;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ import java.util.Set;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,6 +56,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
|
|
||||||
private static final Pattern FLAG_PRIMARY_PATTERN = Pattern.compile(" --(?<name>([A-Za-z]+))");
|
private static final Pattern FLAG_PRIMARY_PATTERN = Pattern.compile(" --(?<name>([A-Za-z]+))");
|
||||||
|
|
@ -105,6 +107,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class FlagArgumentParser<C> implements ArgumentParser<C, Object> {
|
public static final class FlagArgumentParser<C> implements ArgumentParser<C, Object> {
|
||||||
|
|
||||||
private final CommandFlag<?>[] flags;
|
private final CommandFlag<?>[] flags;
|
||||||
|
|
@ -289,6 +292,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
return this.suggestions(commandContext, input);
|
return this.suggestions(commandContext, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to parse the command input queue into flags
|
* Helper class to parse the command input queue into flags
|
||||||
* and flag values. On failure the intermediate results
|
* and flag values. On failure the intermediate results
|
||||||
|
|
@ -472,9 +476,11 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag parse exception
|
* Flag parse exception
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class FlagParseException extends ParserException {
|
public static final class FlagParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -7725389394142868549L;
|
private static final long serialVersionUID = -7725389394142868549L;
|
||||||
|
|
@ -513,9 +519,11 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reasons for which flag parsing may fail
|
* Reasons for which flag parsing may fail
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public enum FailureReason {
|
public enum FailureReason {
|
||||||
|
|
||||||
UNKNOWN_FLAG(StandardCaptionKeys.ARGUMENT_PARSE_FAILURE_FLAG_UNKNOWN_FLAG),
|
UNKNOWN_FLAG(StandardCaptionKeys.ARGUMENT_PARSE_FAILURE_FLAG_UNKNOWN_FLAG),
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -43,6 +44,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @param <T> Command argument type. {@link Void} is used when no argument is present.
|
* @param <T> Command argument type. {@link Void} is used when no argument is present.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class CommandFlag<T> {
|
public final class CommandFlag<T> {
|
||||||
|
|
||||||
private final @NonNull String name;
|
private final @NonNull String name;
|
||||||
|
|
@ -101,6 +103,7 @@ public final class CommandFlag<T> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #getArgumentDescription()} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #getArgumentDescription()} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public cloud.commandframework.@NonNull Description getDescription() {
|
public cloud.commandframework.@NonNull Description getDescription() {
|
||||||
if (this.description instanceof cloud.commandframework.Description) {
|
if (this.description instanceof cloud.commandframework.Description) {
|
||||||
return ((cloud.commandframework.Description) this.description);
|
return ((cloud.commandframework.Description) this.description);
|
||||||
|
|
@ -115,6 +118,7 @@ public final class CommandFlag<T> {
|
||||||
* @return Flag description
|
* @return Flag description
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public @NonNull ArgumentDescription getArgumentDescription() {
|
public @NonNull ArgumentDescription getArgumentDescription() {
|
||||||
return this.description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
@ -134,6 +138,7 @@ public final class CommandFlag<T> {
|
||||||
* @return Command permission, or {@code null}
|
* @return Command permission, or {@code null}
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
public CommandPermission permission() {
|
public CommandPermission permission() {
|
||||||
return this.permission;
|
return this.permission;
|
||||||
}
|
}
|
||||||
|
|
@ -161,6 +166,7 @@ public final class CommandFlag<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<T> {
|
public static final class Builder<T> {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
@ -227,6 +233,7 @@ public final class CommandFlag<T> {
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #withDescription(ArgumentDescription)} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #withDescription(ArgumentDescription)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.4.0")
|
||||||
public Builder<T> withDescription(final cloud.commandframework.@NonNull Description description) {
|
public Builder<T> withDescription(final cloud.commandframework.@NonNull Description description) {
|
||||||
return this.withDescription((ArgumentDescription) description);
|
return this.withDescription((ArgumentDescription) description);
|
||||||
}
|
}
|
||||||
|
|
@ -238,6 +245,7 @@ public final class CommandFlag<T> {
|
||||||
* @return New builder instance
|
* @return New builder instance
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public Builder<T> withDescription(final @NonNull ArgumentDescription description) {
|
public Builder<T> withDescription(final @NonNull ArgumentDescription description) {
|
||||||
return new Builder<>(this.name, this.aliases, description, this.permission, this.commandArgument);
|
return new Builder<>(this.name, this.aliases, description, this.permission, this.commandArgument);
|
||||||
}
|
}
|
||||||
|
|
@ -271,6 +279,7 @@ public final class CommandFlag<T> {
|
||||||
* @return New builder instance
|
* @return New builder instance
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
public Builder<T> withPermission(final @NonNull CommandPermission permission) {
|
public Builder<T> withPermission(final @NonNull CommandPermission permission) {
|
||||||
return new Builder<>(this.name, this.aliases, this.description, permission, this.commandArgument);
|
return new Builder<>(this.name, this.aliases, this.description, permission, this.commandArgument);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,14 @@ package cloud.commandframework.arguments.flags;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag value mappings
|
* Flag value mappings
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class FlagContext {
|
public final class FlagContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -99,6 +101,7 @@ public final class FlagContext {
|
||||||
* else {@code false}
|
* else {@code false}
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public boolean isPresent(final @NonNull CommandFlag<Void> flag) {
|
public boolean isPresent(final @NonNull CommandFlag<Void> flag) {
|
||||||
return this.isPresent(flag.getName());
|
return this.isPresent(flag.getName());
|
||||||
}
|
}
|
||||||
|
|
@ -111,6 +114,7 @@ public final class FlagContext {
|
||||||
* @return Optional containing stored value if present
|
* @return Optional containing stored value if present
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public <T> @NonNull Optional<T> getValue(
|
public <T> @NonNull Optional<T> getValue(
|
||||||
final @NonNull String name
|
final @NonNull String name
|
||||||
) {
|
) {
|
||||||
|
|
@ -130,6 +134,7 @@ public final class FlagContext {
|
||||||
* @return Optional containing stored value if present
|
* @return Optional containing stored value if present
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @NonNull Optional<T> getValue(
|
public <T> @NonNull Optional<T> getValue(
|
||||||
final @NonNull CommandFlag<T> flag
|
final @NonNull CommandFlag<T> flag
|
||||||
) {
|
) {
|
||||||
|
|
@ -160,6 +165,7 @@ public final class FlagContext {
|
||||||
* @return Stored value, or the supplied default value
|
* @return Stored value, or the supplied default value
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @Nullable T getValue(
|
public <T> @Nullable T getValue(
|
||||||
final @NonNull CommandFlag<T> name,
|
final @NonNull CommandFlag<T> name,
|
||||||
final @Nullable T defaultValue
|
final @Nullable T defaultValue
|
||||||
|
|
@ -176,6 +182,7 @@ public final class FlagContext {
|
||||||
* @return whether the flag is present
|
* @return whether the flag is present
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public boolean hasFlag(
|
public boolean hasFlag(
|
||||||
final @NonNull String name
|
final @NonNull String name
|
||||||
) {
|
) {
|
||||||
|
|
@ -191,6 +198,7 @@ public final class FlagContext {
|
||||||
* @return whether the flag is present
|
* @return whether the flag is present
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public boolean hasFlag(
|
public boolean hasFlag(
|
||||||
final @NonNull CommandFlag<?> flag
|
final @NonNull CommandFlag<?> flag
|
||||||
) {
|
) {
|
||||||
|
|
@ -206,6 +214,7 @@ public final class FlagContext {
|
||||||
* @return whether the flag is present
|
* @return whether the flag is present
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public boolean contains(final @NonNull String name) {
|
public boolean contains(final @NonNull String name) {
|
||||||
return this.hasFlag(name);
|
return this.hasFlag(name);
|
||||||
}
|
}
|
||||||
|
|
@ -219,6 +228,7 @@ public final class FlagContext {
|
||||||
* @return whether the flag is present
|
* @return whether the flag is present
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public boolean contains(final @NonNull CommandFlag<?> flag) {
|
public boolean contains(final @NonNull CommandFlag<?> flag) {
|
||||||
return this.hasFlag(flag);
|
return this.hasFlag(flag);
|
||||||
}
|
}
|
||||||
|
|
@ -232,6 +242,7 @@ public final class FlagContext {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
@SuppressWarnings("TypeParameterUnusedInFormals")
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public <T> @Nullable T get(
|
public <T> @Nullable T get(
|
||||||
final @NonNull String name
|
final @NonNull String name
|
||||||
) {
|
) {
|
||||||
|
|
@ -246,6 +257,7 @@ public final class FlagContext {
|
||||||
* @return Stored value if present, else {@code null}
|
* @return Stored value if present, else {@code null}
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @Nullable T get(
|
public <T> @Nullable T get(
|
||||||
final @NonNull CommandFlag<T> flag
|
final @NonNull CommandFlag<T> flag
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.arguments.parser;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
|
|
@ -33,6 +34,7 @@ import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
*
|
*
|
||||||
* @param <T> Parser return type
|
* @param <T> Parser return type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public abstract class ArgumentParseResult<T> {
|
public abstract class ArgumentParseResult<T> {
|
||||||
|
|
||||||
private ArgumentParseResult() {
|
private ArgumentParseResult() {
|
||||||
|
|
@ -75,6 +77,7 @@ public abstract class ArgumentParseResult<T> {
|
||||||
* @return a new result if successful, otherwise a failure
|
* @return a new result if successful, otherwise a failure
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public abstract <U> @NonNull ArgumentParseResult<U> mapParsedValue(Function<T, U> mapper);
|
public abstract <U> @NonNull ArgumentParseResult<U> mapParsedValue(Function<T, U> mapper);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -85,6 +88,7 @@ public abstract class ArgumentParseResult<T> {
|
||||||
* @return a new result if successful, otherwise a failure
|
* @return a new result if successful, otherwise a failure
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public abstract <U> @NonNull ArgumentParseResult<U> flatMapParsedValue(Function<T, ArgumentParseResult<U>> mapper);
|
public abstract <U> @NonNull ArgumentParseResult<U> flatMapParsedValue(Function<T, ArgumentParseResult<U>> mapper);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -101,6 +105,7 @@ public abstract class ArgumentParseResult<T> {
|
||||||
* @return if this is a failure, a transformed result, otherwise this
|
* @return if this is a failure, a transformed result, otherwise this
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public abstract @NonNull ArgumentParseResult<T> mapFailure(Function<Throwable, Throwable> mapper);
|
public abstract @NonNull ArgumentParseResult<T> mapFailure(Function<Throwable, Throwable> mapper);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -160,13 +165,13 @@ public abstract class ArgumentParseResult<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public @NonNull <U> ArgumentParseResult<U> mapParsedValue(final Function<T, U> mapper) {
|
public @NonNull <U> @This ArgumentParseResult<U> mapParsedValue(final Function<T, U> mapper) {
|
||||||
return (ArgumentParseResult<U>) this;
|
return (ArgumentParseResult<U>) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public @NonNull <U> ArgumentParseResult<U> flatMapParsedValue(final Function<T, ArgumentParseResult<U>> mapper) {
|
public @NonNull <U> @This ArgumentParseResult<U> flatMapParsedValue(final Function<T, ArgumentParseResult<U>> mapper) {
|
||||||
return (ArgumentParseResult<U>) this;
|
return (ArgumentParseResult<U>) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
@ -39,6 +40,7 @@ import static java.util.Objects.requireNonNull;
|
||||||
* @param <T> Value type
|
* @param <T> Value type
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface ArgumentParser<C, T> {
|
public interface ArgumentParser<C, T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -99,12 +101,13 @@ public interface ArgumentParser<C, T> {
|
||||||
* @return a derived parser.
|
* @return a derived parser.
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
default <O> @NonNull ArgumentParser<C, O> map(final BiFunction<CommandContext<C>, T, ArgumentParseResult<O>> mapper) {
|
default <O> @NonNull ArgumentParser<C, O> map(final BiFunction<CommandContext<C>, T, ArgumentParseResult<O>> mapper) {
|
||||||
return new MappedArgumentParser<>(this, requireNonNull(mapper, "mapper"));
|
return new MappedArgumentParser<>(this, requireNonNull(mapper, "mapper"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether or not this argument parser is context free. A context free
|
* Check whether this argument parser is context free. A context free
|
||||||
* parser will not use the provided command context, and so supports impromptu parsing
|
* parser will not use the provided command context, and so supports impromptu parsing
|
||||||
*
|
*
|
||||||
* @return {@code true} if the parser is context free, else {@code false}
|
* @return {@code true} if the parser is context free, else {@code false}
|
||||||
|
|
@ -120,6 +123,7 @@ public interface ArgumentParser<C, T> {
|
||||||
* @return The number of arguments tha the parser expects
|
* @return The number of arguments tha the parser expects
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.1.0")
|
||||||
default int getRequestedArgumentCount() {
|
default int getRequestedArgumentCount() {
|
||||||
return DEFAULT_ARGUMENT_COUNT;
|
return DEFAULT_ARGUMENT_COUNT;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -38,6 +39,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @param <O> mapped output type
|
* @param <O> mapped output type
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public final class MappedArgumentParser<C, I, O> implements ArgumentParser<C, O> {
|
public final class MappedArgumentParser<C, I, O> implements ArgumentParser<C, O> {
|
||||||
private final ArgumentParser<C, I> base;
|
private final ArgumentParser<C, I> base;
|
||||||
private final BiFunction<CommandContext<C>, I, ArgumentParseResult<O>> mapper;
|
private final BiFunction<CommandContext<C>, I, ArgumentParseResult<O>> mapper;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.arguments.parser;
|
||||||
|
|
||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <T> Type required by the parameter
|
* @param <T> Type required by the parameter
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class ParserParameter<T> {
|
public class ParserParameter<T> {
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,13 @@ package cloud.commandframework.arguments.parser;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of {@link ParserParameter parameter}-{@link Object object} pairs
|
* Collection of {@link ParserParameter parameter}-{@link Object object} pairs
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class ParserParameters {
|
public final class ParserParameters {
|
||||||
|
|
||||||
private final Map<ParserParameter<?>, Object> internalMap = new HashMap<>();
|
private final Map<ParserParameter<?>, Object> internalMap = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,6 +41,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface ParserRegistry<C> {
|
public interface ParserRegistry<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -130,6 +132,7 @@ public interface ParserRegistry<C> {
|
||||||
* @see #getSuggestionProvider(String) Get a suggestion provider
|
* @see #getSuggestionProvider(String) Get a suggestion provider
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.1.0")
|
||||||
void registerSuggestionProvider(
|
void registerSuggestionProvider(
|
||||||
@NonNull String name,
|
@NonNull String name,
|
||||||
@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>> suggestionsProvider
|
@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>> suggestionsProvider
|
||||||
|
|
@ -144,6 +147,7 @@ public interface ParserRegistry<C> {
|
||||||
* @see #registerSuggestionProvider(String, BiFunction) Register a suggestion provider
|
* @see #registerSuggestionProvider(String, BiFunction) Register a suggestion provider
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.1.0")
|
||||||
@NonNull Optional<BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>>> getSuggestionProvider(
|
@NonNull Optional<BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>>> getSuggestionProvider(
|
||||||
@NonNull String name
|
@NonNull String name
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,13 @@
|
||||||
package cloud.commandframework.arguments.parser;
|
package cloud.commandframework.arguments.parser;
|
||||||
|
|
||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common parser parameters used when resolving types in the {@link ParserRegistry}
|
* Common parser parameters used when resolving types in the {@link ParserRegistry}
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class StandardParameters {
|
public final class StandardParameters {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -65,6 +67,7 @@ public final class StandardParameters {
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
* @see cloud.commandframework.annotations.specifier.FlagYielding
|
* @see cloud.commandframework.annotations.specifier.FlagYielding
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public static final ParserParameter<Boolean> FLAG_YIELDING = create(
|
public static final ParserParameter<Boolean> FLAG_YIELDING = create(
|
||||||
"flag_yielding",
|
"flag_yielding",
|
||||||
TypeToken.get(Boolean.class)
|
TypeToken.get(Boolean.class)
|
||||||
|
|
@ -74,12 +77,14 @@ public final class StandardParameters {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final ParserParameter<Boolean> QUOTED = create("quoted", TypeToken.get(Boolean.class));
|
public static final ParserParameter<Boolean> QUOTED = create("quoted", TypeToken.get(Boolean.class));
|
||||||
/**
|
/**
|
||||||
* Indicates that a boolean argument should be liberal.
|
* Indicates that a boolean argument should be liberal.
|
||||||
*
|
*
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
public static final ParserParameter<Boolean> LIBERAL = create("liberal", TypeToken.get(Boolean.class));
|
public static final ParserParameter<Boolean> LIBERAL = create("liberal", TypeToken.get(Boolean.class));
|
||||||
|
|
||||||
private StandardParameters() {
|
private StandardParameters() {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,6 +65,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "unchecked", "rawtypes"})
|
@SuppressWarnings({"unused", "unchecked", "rawtypes"})
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class StandardParserRegistry<C> implements ParserRegistry<C> {
|
public final class StandardParserRegistry<C> implements ParserRegistry<C> {
|
||||||
|
|
||||||
@SuppressWarnings({"DoubleBraceInitialization"})
|
@SuppressWarnings({"DoubleBraceInitialization"})
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,6 +42,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
|
public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
|
||||||
@NonNull ArgumentParseResult<Boolean>> {
|
@NonNull ArgumentParseResult<Boolean>> {
|
||||||
|
|
||||||
|
|
@ -113,6 +115,7 @@ public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandCo
|
||||||
* Exception thrown when input fails regex matching in {@link RegexPreprocessor}
|
* Exception thrown when input fails regex matching in {@link RegexPreprocessor}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class RegexValidationException extends IllegalArgumentException {
|
public static final class RegexValidationException extends IllegalArgumentException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 747826566058072233L;
|
private static final long serialVersionUID = 747826566058072233L;
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,13 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
||||||
|
|
||||||
private final boolean liberal;
|
private final boolean liberal;
|
||||||
|
|
@ -116,6 +118,8 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
||||||
return this.liberal;
|
return this.liberal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Boolean> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Boolean> {
|
||||||
|
|
||||||
private boolean liberal = false;
|
private boolean liberal = false;
|
||||||
|
|
@ -154,6 +158,8 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class BooleanParser<C> implements ArgumentParser<C, Boolean> {
|
public static final class BooleanParser<C> implements ArgumentParser<C, Boolean> {
|
||||||
|
|
||||||
private static final List<String> LIBERAL = Arrays.asList("TRUE", "YES", "ON", "FALSE", "NO", "OFF");
|
private static final List<String> LIBERAL = Arrays.asList("TRUE", "YES", "ON", "FALSE", "NO", "OFF");
|
||||||
|
|
@ -236,6 +242,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
||||||
/**
|
/**
|
||||||
* Boolean parse exception
|
* Boolean parse exception
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class BooleanParseException extends ParserException {
|
public static final class BooleanParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2688852086944850025L;
|
private static final long serialVersionUID = -2688852086944850025L;
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
|
|
||||||
private final byte min;
|
private final byte min;
|
||||||
|
|
@ -125,6 +127,8 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
return this.max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Byte> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Byte> {
|
||||||
|
|
||||||
private byte min = ByteParser.DEFAULT_MINIMUM;
|
private byte min = ByteParser.DEFAULT_MINIMUM;
|
||||||
|
|
@ -164,6 +168,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public @NonNull Builder<C> asOptionalWithDefault(final byte defaultValue) {
|
public @NonNull Builder<C> asOptionalWithDefault(final byte defaultValue) {
|
||||||
return (Builder<C>) this.asOptionalWithDefault(Byte.toString(defaultValue));
|
return (Builder<C>) this.asOptionalWithDefault(Byte.toString(defaultValue));
|
||||||
}
|
}
|
||||||
|
|
@ -182,6 +187,8 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class ByteParser<C> implements ArgumentParser<C, Byte> {
|
public static final class ByteParser<C> implements ArgumentParser<C, Byte> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -189,6 +196,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final byte DEFAULT_MINIMUM = Byte.MIN_VALUE;
|
public static final byte DEFAULT_MINIMUM = Byte.MIN_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -196,6 +204,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final byte DEFAULT_MAXIMUM = Byte.MAX_VALUE;
|
public static final byte DEFAULT_MAXIMUM = Byte.MAX_VALUE;
|
||||||
|
|
||||||
private final byte min;
|
private final byte min;
|
||||||
|
|
@ -271,6 +280,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
* @return whether the parser has a maximum set
|
* @return whether the parser has a maximum set
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public boolean hasMax() {
|
public boolean hasMax() {
|
||||||
return this.max != DEFAULT_MAXIMUM;
|
return this.max != DEFAULT_MAXIMUM;
|
||||||
}
|
}
|
||||||
|
|
@ -282,6 +292,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
* @return whether the parser has a maximum set
|
* @return whether the parser has a maximum set
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public boolean hasMin() {
|
public boolean hasMin() {
|
||||||
return this.min != DEFAULT_MINIMUM;
|
return this.min != DEFAULT_MINIMUM;
|
||||||
}
|
}
|
||||||
|
|
@ -309,6 +320,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
* @deprecated use {@link #ByteParseException(String, ByteParser, CommandContext)} instead
|
* @deprecated use {@link #ByteParseException(String, ByteParser, CommandContext)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.5.0")
|
||||||
public ByteParseException(
|
public ByteParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final byte min,
|
final byte min,
|
||||||
|
|
@ -326,6 +338,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
||||||
* @param context command context
|
* @param context command context
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public ByteParseException(
|
public ByteParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final @NonNull ByteParser<?> parser,
|
final @NonNull ByteParser<?> parser,
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,12 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class CharArgument<C> extends CommandArgument<C, Character> {
|
public final class CharArgument<C> extends CommandArgument<C, Character> {
|
||||||
|
|
||||||
private CharArgument(
|
private CharArgument(
|
||||||
|
|
@ -102,6 +104,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Character> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Character> {
|
||||||
|
|
||||||
private Builder(final @NonNull String name) {
|
private Builder(final @NonNull String name) {
|
||||||
|
|
@ -123,6 +126,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class CharacterParser<C> implements ArgumentParser<C, Character> {
|
public static final class CharacterParser<C> implements ArgumentParser<C, Character> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -157,6 +161,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
|
||||||
/**
|
/**
|
||||||
* Char parse exception
|
* Char parse exception
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class CharParseException extends ParserException {
|
public static final class CharParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 6458851071584278854L;
|
private static final long serialVersionUID = 6458851071584278854L;
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
||||||
|
|
||||||
private final double min;
|
private final double min;
|
||||||
|
|
@ -125,6 +127,8 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
||||||
return this.max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Double> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Double> {
|
||||||
|
|
||||||
private double min = DoubleParser.DEFAULT_MINIMUM;
|
private double min = DoubleParser.DEFAULT_MINIMUM;
|
||||||
|
|
@ -164,6 +168,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
||||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public @NonNull Builder<C> asOptionalWithDefault(final double defaultValue) {
|
public @NonNull Builder<C> asOptionalWithDefault(final double defaultValue) {
|
||||||
return (Builder<C>) this.asOptionalWithDefault(Double.toString(defaultValue));
|
return (Builder<C>) this.asOptionalWithDefault(Double.toString(defaultValue));
|
||||||
}
|
}
|
||||||
|
|
@ -182,6 +187,8 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class DoubleParser<C> implements ArgumentParser<C, Double> {
|
public static final class DoubleParser<C> implements ArgumentParser<C, Double> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -189,6 +196,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final double DEFAULT_MINIMUM = Double.NEGATIVE_INFINITY;
|
public static final double DEFAULT_MINIMUM = Double.NEGATIVE_INFINITY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -196,6 +204,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final double DEFAULT_MAXIMUM = Double.POSITIVE_INFINITY;
|
public static final double DEFAULT_MAXIMUM = Double.POSITIVE_INFINITY;
|
||||||
|
|
||||||
private final double min;
|
private final double min;
|
||||||
|
|
@ -282,6 +291,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class DoubleParseException extends NumberParseException {
|
public static final class DoubleParseException extends NumberParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1764554911581976586L;
|
private static final long serialVersionUID = 1764554911581976586L;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -52,6 +53,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @param <C> sender type
|
* @param <C> sender type
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public final class DurationArgument<C> extends CommandArgument<C, Duration> {
|
public final class DurationArgument<C> extends CommandArgument<C, Duration> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -153,6 +155,7 @@ public final class DurationArgument<C> extends CommandArgument<C, Duration> {
|
||||||
* @param <C> sender type
|
* @param <C> sender type
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public static final class Builder<C> extends TypedBuilder<C, Duration, Builder<C>> {
|
public static final class Builder<C> extends TypedBuilder<C, Duration, Builder<C>> {
|
||||||
|
|
||||||
private Builder(final @NonNull String name) {
|
private Builder(final @NonNull String name) {
|
||||||
|
|
@ -197,6 +200,7 @@ public final class DurationArgument<C> extends CommandArgument<C, Duration> {
|
||||||
* @param <C> sender type
|
* @param <C> sender type
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public static final class Parser<C> implements ArgumentParser<C, Duration> {
|
public static final class Parser<C> implements ArgumentParser<C, Duration> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -281,6 +285,7 @@ public final class DurationArgument<C> extends CommandArgument<C, Duration> {
|
||||||
*
|
*
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public static final class DurationParseException extends ParserException {
|
public static final class DurationParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7632293268451349508L;
|
private static final long serialVersionUID = 7632293268451349508L;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -48,6 +49,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @param <E> Enum type
|
* @param <E> Enum type
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
|
public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
|
||||||
|
|
||||||
protected EnumArgument(
|
protected EnumArgument(
|
||||||
|
|
@ -129,6 +131,7 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C, E extends Enum<E>> extends CommandArgument.Builder<C, E> {
|
public static final class Builder<C, E extends Enum<E>> extends CommandArgument.Builder<C, E> {
|
||||||
|
|
||||||
private final Class<E> enumClass;
|
private final Class<E> enumClass;
|
||||||
|
|
@ -148,6 +151,7 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class EnumParser<C, E extends Enum<E>> implements ArgumentParser<C, E> {
|
public static final class EnumParser<C, E extends Enum<E>> implements ArgumentParser<C, E> {
|
||||||
|
|
||||||
private final Class<E> enumClass;
|
private final Class<E> enumClass;
|
||||||
|
|
@ -202,6 +206,7 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class EnumParseException extends ParserException {
|
public static final class EnumParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3465389578951428862L;
|
private static final long serialVersionUID = 3465389578951428862L;
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
|
|
||||||
private final float min;
|
private final float min;
|
||||||
|
|
@ -125,6 +127,8 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
return this.max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Float> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Float> {
|
||||||
|
|
||||||
private float min = FloatParser.DEFAULT_MINIMUM;
|
private float min = FloatParser.DEFAULT_MINIMUM;
|
||||||
|
|
@ -164,6 +168,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public @NonNull Builder<C> asOptionalWithDefault(final float defaultValue) {
|
public @NonNull Builder<C> asOptionalWithDefault(final float defaultValue) {
|
||||||
return (Builder<C>) this.asOptionalWithDefault(Float.toString(defaultValue));
|
return (Builder<C>) this.asOptionalWithDefault(Float.toString(defaultValue));
|
||||||
}
|
}
|
||||||
|
|
@ -177,6 +182,8 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class FloatParser<C> implements ArgumentParser<C, Float> {
|
public static final class FloatParser<C> implements ArgumentParser<C, Float> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -184,6 +191,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final float DEFAULT_MINIMUM = Float.NEGATIVE_INFINITY;
|
public static final float DEFAULT_MINIMUM = Float.NEGATIVE_INFINITY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -191,6 +199,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final float DEFAULT_MAXIMUM = Float.POSITIVE_INFINITY;
|
public static final float DEFAULT_MAXIMUM = Float.POSITIVE_INFINITY;
|
||||||
|
|
||||||
private final float min;
|
private final float min;
|
||||||
|
|
@ -258,6 +267,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
* @return whether the parser has a maximum set
|
* @return whether the parser has a maximum set
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public boolean hasMax() {
|
public boolean hasMax() {
|
||||||
return this.max != DEFAULT_MAXIMUM;
|
return this.max != DEFAULT_MAXIMUM;
|
||||||
}
|
}
|
||||||
|
|
@ -269,6 +279,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
* @return whether the parser has a maximum set
|
* @return whether the parser has a maximum set
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public boolean hasMin() {
|
public boolean hasMin() {
|
||||||
return this.min != DEFAULT_MINIMUM;
|
return this.min != DEFAULT_MINIMUM;
|
||||||
}
|
}
|
||||||
|
|
@ -277,6 +288,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class FloatParseException extends NumberParseException {
|
public static final class FloatParseException extends NumberParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1162983846751812292L;
|
private static final long serialVersionUID = -1162983846751812292L;
|
||||||
|
|
@ -293,6 +305,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
* @deprecated use {@link #FloatParseException(String, FloatParser, CommandContext)} instead
|
* @deprecated use {@link #FloatParseException(String, FloatParser, CommandContext)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.5.0")
|
||||||
public FloatParseException(
|
public FloatParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final float min,
|
final float min,
|
||||||
|
|
@ -310,6 +323,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
* @param commandContext command context
|
* @param commandContext command context
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public FloatParseException(
|
public FloatParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final @NonNull FloatParser<?> parser,
|
final @NonNull FloatParser<?> parser,
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,13 @@ import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
|
|
||||||
private static final int MAX_SUGGESTIONS_INCREMENT = 10;
|
private static final int MAX_SUGGESTIONS_INCREMENT = 10;
|
||||||
|
|
@ -137,6 +139,8 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
return this.max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Integer> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Integer> {
|
||||||
|
|
||||||
private int min = IntegerParser.DEFAULT_MINIMUM;
|
private int min = IntegerParser.DEFAULT_MINIMUM;
|
||||||
|
|
@ -176,6 +180,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public @NonNull Builder<C> asOptionalWithDefault(final int defaultValue) {
|
public @NonNull Builder<C> asOptionalWithDefault(final int defaultValue) {
|
||||||
return (Builder<C>) this.asOptionalWithDefault(Integer.toString(defaultValue));
|
return (Builder<C>) this.asOptionalWithDefault(Integer.toString(defaultValue));
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +194,8 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class IntegerParser<C> implements ArgumentParser<C, Integer> {
|
public static final class IntegerParser<C> implements ArgumentParser<C, Integer> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -196,6 +203,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final int DEFAULT_MINIMUM = Integer.MIN_VALUE;
|
public static final int DEFAULT_MINIMUM = Integer.MIN_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -203,6 +211,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final int DEFAULT_MAXIMUM = Integer.MAX_VALUE;
|
public static final int DEFAULT_MAXIMUM = Integer.MAX_VALUE;
|
||||||
|
|
||||||
private final int min;
|
private final int min;
|
||||||
|
|
@ -340,6 +349,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class IntegerParseException extends NumberParseException {
|
public static final class IntegerParseException extends NumberParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -6933923056628373853L;
|
private static final long serialVersionUID = -6933923056628373853L;
|
||||||
|
|
@ -356,6 +366,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
* @deprecated use {@link #IntegerParseException(String, IntegerParser, CommandContext)} instead
|
* @deprecated use {@link #IntegerParseException(String, IntegerParser, CommandContext)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.5.0")
|
||||||
public IntegerParseException(
|
public IntegerParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final int min,
|
final int min,
|
||||||
|
|
@ -373,6 +384,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
||||||
* @param commandContext command context
|
* @param commandContext command context
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public IntegerParseException(
|
public IntegerParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final @NonNull IntegerParser<?> parser,
|
final @NonNull IntegerParser<?> parser,
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class LongArgument<C> extends CommandArgument<C, Long> {
|
public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
|
|
||||||
private final long min;
|
private final long min;
|
||||||
|
|
@ -125,6 +127,8 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
return this.max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Long> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Long> {
|
||||||
|
|
||||||
private long min = LongParser.DEFAULT_MINIMUM;
|
private long min = LongParser.DEFAULT_MINIMUM;
|
||||||
|
|
@ -164,6 +168,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public @NonNull Builder<C> asOptionalWithDefault(final long defaultValue) {
|
public @NonNull Builder<C> asOptionalWithDefault(final long defaultValue) {
|
||||||
return (Builder<C>) this.asOptionalWithDefault(Long.toString(defaultValue));
|
return (Builder<C>) this.asOptionalWithDefault(Long.toString(defaultValue));
|
||||||
}
|
}
|
||||||
|
|
@ -177,6 +182,8 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class LongParser<C> implements ArgumentParser<C, Long> {
|
public static final class LongParser<C> implements ArgumentParser<C, Long> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -184,6 +191,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final long DEFAULT_MINIMUM = Long.MIN_VALUE;
|
public static final long DEFAULT_MINIMUM = Long.MIN_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -191,6 +199,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final long DEFAULT_MAXIMUM = Long.MAX_VALUE;
|
public static final long DEFAULT_MAXIMUM = Long.MAX_VALUE;
|
||||||
|
|
||||||
private final long min;
|
private final long min;
|
||||||
|
|
@ -253,6 +262,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
* @return whether the parser has a maximum set
|
* @return whether the parser has a maximum set
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public boolean hasMax() {
|
public boolean hasMax() {
|
||||||
return this.max != DEFAULT_MAXIMUM;
|
return this.max != DEFAULT_MAXIMUM;
|
||||||
}
|
}
|
||||||
|
|
@ -264,6 +274,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
* @return whether the parser has a maximum set
|
* @return whether the parser has a maximum set
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public boolean hasMin() {
|
public boolean hasMin() {
|
||||||
return this.min != DEFAULT_MINIMUM;
|
return this.min != DEFAULT_MINIMUM;
|
||||||
}
|
}
|
||||||
|
|
@ -285,6 +296,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class LongParseException extends NumberParseException {
|
public static final class LongParseException extends NumberParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 4366856282301198232L;
|
private static final long serialVersionUID = 4366856282301198232L;
|
||||||
|
|
@ -301,6 +313,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
* @deprecated use {@link #LongParseException(String, LongParser, CommandContext)} instead
|
* @deprecated use {@link #LongParseException(String, LongParser, CommandContext)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.5.0")
|
||||||
public LongParseException(
|
public LongParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final long min,
|
final long min,
|
||||||
|
|
@ -318,6 +331,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
||||||
* @param commandContext command context
|
* @param commandContext command context
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public LongParseException(
|
public LongParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final @NonNull LongParser<?> parser,
|
final @NonNull LongParser<?> parser,
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
|
|
||||||
private final short min;
|
private final short min;
|
||||||
|
|
@ -122,6 +124,8 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
return this.max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Short> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Short> {
|
||||||
|
|
||||||
private short min = ShortParser.DEFAULT_MINIMUM;
|
private short min = ShortParser.DEFAULT_MINIMUM;
|
||||||
|
|
@ -161,6 +165,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public @NonNull Builder<C> asOptionalWithDefault(final short defaultValue) {
|
public @NonNull Builder<C> asOptionalWithDefault(final short defaultValue) {
|
||||||
return (Builder<C>) this.asOptionalWithDefault(Short.toString(defaultValue));
|
return (Builder<C>) this.asOptionalWithDefault(Short.toString(defaultValue));
|
||||||
}
|
}
|
||||||
|
|
@ -174,6 +179,8 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class ShortParser<C> implements ArgumentParser<C, Short> {
|
public static final class ShortParser<C> implements ArgumentParser<C, Short> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -181,6 +188,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final short DEFAULT_MINIMUM = Short.MIN_VALUE;
|
public static final short DEFAULT_MINIMUM = Short.MIN_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -188,6 +196,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final short DEFAULT_MAXIMUM = Short.MAX_VALUE;
|
public static final short DEFAULT_MAXIMUM = Short.MAX_VALUE;
|
||||||
|
|
||||||
private final short min;
|
private final short min;
|
||||||
|
|
@ -263,6 +272,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
* @return whether the parser has a maximum set
|
* @return whether the parser has a maximum set
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public boolean hasMax() {
|
public boolean hasMax() {
|
||||||
return this.max != DEFAULT_MAXIMUM;
|
return this.max != DEFAULT_MAXIMUM;
|
||||||
}
|
}
|
||||||
|
|
@ -274,6 +284,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
* @return whether the parser has a maximum set
|
* @return whether the parser has a maximum set
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public boolean hasMin() {
|
public boolean hasMin() {
|
||||||
return this.min != DEFAULT_MINIMUM;
|
return this.min != DEFAULT_MINIMUM;
|
||||||
}
|
}
|
||||||
|
|
@ -282,6 +293,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public static final class ShortParseException extends NumberParseException {
|
public static final class ShortParseException extends NumberParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -478674263339091032L;
|
private static final long serialVersionUID = -478674263339091032L;
|
||||||
|
|
@ -298,6 +310,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
* @deprecated use {@link #ShortParseException(String, ShortParser, CommandContext)} instead
|
* @deprecated use {@link #ShortParseException(String, ShortParser, CommandContext)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.5.0")
|
||||||
public ShortParseException(
|
public ShortParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final short min,
|
final short min,
|
||||||
|
|
@ -315,6 +328,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
||||||
* @param commandContext command context
|
* @param commandContext command context
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.5.0")
|
||||||
public ShortParseException(
|
public ShortParseException(
|
||||||
final @NonNull String input,
|
final @NonNull String input,
|
||||||
final @NonNull ShortParser<?> parser,
|
final @NonNull ShortParser<?> parser,
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,12 @@ import java.util.StringJoiner;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class StringArgument<C> extends CommandArgument<C, String> {
|
public final class StringArgument<C> extends CommandArgument<C, String> {
|
||||||
|
|
||||||
private static final Pattern QUOTED_DOUBLE = Pattern.compile("\"(?<inner>(?:[^\"\\\\]|\\\\.)*)\"");
|
private static final Pattern QUOTED_DOUBLE = Pattern.compile("\"(?<inner>(?:[^\"\\\\]|\\\\.)*)\"");
|
||||||
|
|
@ -174,6 +176,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
||||||
* @return Created argument
|
* @return Created argument
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public static <C> @NonNull CommandArgument<C, String> greedyFlagYielding(final @NonNull String name) {
|
public static <C> @NonNull CommandArgument<C, String> greedyFlagYielding(final @NonNull String name) {
|
||||||
return of(name, StringMode.GREEDY_FLAG_YIELDING);
|
return of(name, StringMode.GREEDY_FLAG_YIELDING);
|
||||||
}
|
}
|
||||||
|
|
@ -199,6 +202,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public enum StringMode {
|
public enum StringMode {
|
||||||
SINGLE,
|
SINGLE,
|
||||||
QUOTED,
|
QUOTED,
|
||||||
|
|
@ -208,10 +212,12 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
||||||
*
|
*
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
GREEDY_FLAG_YIELDING
|
GREEDY_FLAG_YIELDING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, String> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, String> {
|
||||||
|
|
||||||
private StringMode stringMode = StringMode.SINGLE;
|
private StringMode stringMode = StringMode.SINGLE;
|
||||||
|
|
@ -248,6 +254,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
||||||
* @return Builder instance
|
* @return Builder instance
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public @NonNull @This Builder<C> greedyFlagYielding() {
|
public @NonNull @This Builder<C> greedyFlagYielding() {
|
||||||
this.stringMode = StringMode.GREEDY_FLAG_YIELDING;
|
this.stringMode = StringMode.GREEDY_FLAG_YIELDING;
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -304,6 +311,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("UnnecessaryLambda")
|
@SuppressWarnings("UnnecessaryLambda")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class StringParser<C> implements ArgumentParser<C, String> {
|
public static final class StringParser<C> implements ArgumentParser<C, String> {
|
||||||
|
|
||||||
private static final Pattern FLAG_PATTERN = Pattern.compile("(-[A-Za-z_\\-0-9])|(--[A-Za-z_\\-0-9]*)");
|
private static final Pattern FLAG_PATTERN = Pattern.compile("(-[A-Za-z_\\-0-9])|(--[A-Za-z_\\-0-9]*)");
|
||||||
|
|
@ -461,6 +469,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class StringParseException extends ParserException {
|
public static final class StringParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8903115465005472945L;
|
private static final long serialVersionUID = -8903115465005472945L;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -44,6 +45,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
||||||
|
|
||||||
private StringArrayArgument(
|
private StringArrayArgument(
|
||||||
|
|
@ -95,6 +97,7 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
||||||
* @return Created argument
|
* @return Created argument
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public static <C> @NonNull StringArrayArgument<C> of(
|
public static <C> @NonNull StringArrayArgument<C> of(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final boolean flagYielding,
|
final boolean flagYielding,
|
||||||
|
|
@ -140,6 +143,7 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
||||||
* @return Created argument
|
* @return Created argument
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public static <C> @NonNull StringArrayArgument<C> optional(
|
public static <C> @NonNull StringArrayArgument<C> optional(
|
||||||
final @NonNull String name,
|
final @NonNull String name,
|
||||||
final boolean flagYielding,
|
final boolean flagYielding,
|
||||||
|
|
@ -160,6 +164,7 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class StringArrayParser<C> implements ArgumentParser<C, String[]> {
|
public static final class StringArrayParser<C> implements ArgumentParser<C, String[]> {
|
||||||
|
|
||||||
private static final Pattern FLAG_PATTERN = Pattern.compile("(-[A-Za-z_\\-0-9])|(--[A-Za-z_\\-0-9]*)");
|
private static final Pattern FLAG_PATTERN = Pattern.compile("(-[A-Za-z_\\-0-9])|(--[A-Za-z_\\-0-9]*)");
|
||||||
|
|
@ -179,6 +184,7 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
|
||||||
* @param flagYielding Whether the parser should stop parsing when encountering a potential flag
|
* @param flagYielding Whether the parser should stop parsing when encountering a potential flag
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
public StringArrayParser(final boolean flagYielding) {
|
public StringArrayParser(final boolean flagYielding) {
|
||||||
this.flagYielding = flagYielding;
|
this.flagYielding = flagYielding;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,12 @@ import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
|
public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
|
||||||
|
|
||||||
private UUIDArgument(
|
private UUIDArgument(
|
||||||
|
|
@ -103,6 +105,7 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, UUID> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, UUID> {
|
||||||
|
|
||||||
private Builder(final @NonNull String name) {
|
private Builder(final @NonNull String name) {
|
||||||
|
|
@ -128,6 +131,7 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class UUIDParser<C> implements ArgumentParser<C, UUID> {
|
public static final class UUIDParser<C> implements ArgumentParser<C, UUID> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -160,6 +164,7 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class UUIDParseException extends ParserException {
|
public static final class UUIDParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 6399602590976540023L;
|
private static final long serialVersionUID = 6399602590976540023L;
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,13 @@
|
||||||
package cloud.commandframework.captions;
|
package cloud.commandframework.captions;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a reference to a caption and does not contain any message itself
|
* This is a reference to a caption and does not contain any message itself
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class Caption {
|
public final class Caption {
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
//
|
//
|
||||||
package cloud.commandframework.captions;
|
package cloud.commandframework.captions;
|
||||||
|
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CaptionRegistry<C> {
|
public interface CaptionRegistry<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,13 @@
|
||||||
//
|
//
|
||||||
package cloud.commandframework.captions;
|
package cloud.commandframework.captions;
|
||||||
|
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key-value pair used to replace variables in captions
|
* Key-value pair used to replace variables in captions
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class CaptionVariable {
|
public final class CaptionVariable {
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,13 @@
|
||||||
//
|
//
|
||||||
package cloud.commandframework.captions;
|
package cloud.commandframework.captions;
|
||||||
|
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility that replaces variables in captions
|
* Utility that replaces variables in captions
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CaptionVariableReplacementHandler {
|
public interface CaptionVariableReplacementHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework.captions;
|
package cloud.commandframework.captions;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface FactoryDelegatingCaptionRegistry<C> extends CaptionRegistry<C> {
|
public interface FactoryDelegatingCaptionRegistry<C> extends CaptionRegistry<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ package cloud.commandframework.captions;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class SimpleCaptionRegistry<C> implements FactoryDelegatingCaptionRegistry<C> {
|
public class SimpleCaptionRegistry<C> implements FactoryDelegatingCaptionRegistry<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
//
|
//
|
||||||
package cloud.commandframework.captions;
|
package cloud.commandframework.captions;
|
||||||
|
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class SimpleCaptionRegistryFactory<C> {
|
public final class SimpleCaptionRegistryFactory<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,13 @@
|
||||||
//
|
//
|
||||||
package cloud.commandframework.captions;
|
package cloud.commandframework.captions;
|
||||||
|
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple implementation of {@link CaptionVariableReplacementHandler}
|
* Simple implementation of {@link CaptionVariableReplacementHandler}
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class SimpleCaptionVariableReplacementHandler implements CaptionVariableReplacementHandler {
|
public final class SimpleCaptionVariableReplacementHandler implements CaptionVariableReplacementHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,13 @@ package cloud.commandframework.captions;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Caption} instances for messages in cloud-core
|
* {@link Caption} instances for messages in cloud-core
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class StandardCaptionKeys {
|
public final class StandardCaptionKeys {
|
||||||
|
|
||||||
private static final Collection<Caption> RECOGNIZED_CAPTIONS = new LinkedList<>();
|
private static final Collection<Caption> RECOGNIZED_CAPTIONS = new LinkedList<>();
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -50,6 +51,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class CommandContext<C> {
|
public class CommandContext<C> {
|
||||||
|
|
||||||
private final CaptionVariableReplacementHandler captionVariableReplacementHandler;
|
private final CaptionVariableReplacementHandler captionVariableReplacementHandler;
|
||||||
|
|
@ -71,6 +73,7 @@ public class CommandContext<C> {
|
||||||
* @deprecated Provide a command manager instead of a caption registry
|
* @deprecated Provide a command manager instead of a caption registry
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.3.0")
|
||||||
public CommandContext(final @NonNull C commandSender, final @NonNull CaptionRegistry<C> captionRegistry) {
|
public CommandContext(final @NonNull C commandSender, final @NonNull CaptionRegistry<C> captionRegistry) {
|
||||||
this(false, commandSender, captionRegistry);
|
this(false, commandSender, captionRegistry);
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +85,7 @@ public class CommandContext<C> {
|
||||||
* @param commandManager Command manager
|
* @param commandManager Command manager
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public CommandContext(final @NonNull C commandSender, final @NonNull CommandManager<C> commandManager) {
|
public CommandContext(final @NonNull C commandSender, final @NonNull CommandManager<C> commandManager) {
|
||||||
this(false, commandSender, commandManager);
|
this(false, commandSender, commandManager);
|
||||||
}
|
}
|
||||||
|
|
@ -89,12 +93,13 @@ public class CommandContext<C> {
|
||||||
/**
|
/**
|
||||||
* Create a new command context instance
|
* Create a new command context instance
|
||||||
*
|
*
|
||||||
* @param suggestions Whether or not the context is created for command suggestions
|
* @param suggestions Whether the context is created for command suggestions
|
||||||
* @param commandSender Sender of the command
|
* @param commandSender Sender of the command
|
||||||
* @param captionRegistry Caption registry
|
* @param captionRegistry Caption registry
|
||||||
* @deprecated Provide a command manager instead of a caption registry
|
* @deprecated Provide a command manager instead of a caption registry
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.3.0")
|
||||||
public CommandContext(
|
public CommandContext(
|
||||||
final boolean suggestions,
|
final boolean suggestions,
|
||||||
final @NonNull C commandSender,
|
final @NonNull C commandSender,
|
||||||
|
|
@ -110,11 +115,12 @@ public class CommandContext<C> {
|
||||||
/**
|
/**
|
||||||
* Create a new command context instance
|
* Create a new command context instance
|
||||||
*
|
*
|
||||||
* @param suggestions Whether or not the context is created for command suggestions
|
* @param suggestions Whether the context is created for command suggestions
|
||||||
* @param commandSender Sender of the command
|
* @param commandSender Sender of the command
|
||||||
* @param commandManager Command manager
|
* @param commandManager Command manager
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public CommandContext(
|
public CommandContext(
|
||||||
final boolean suggestions,
|
final boolean suggestions,
|
||||||
final @NonNull C commandSender,
|
final @NonNull C commandSender,
|
||||||
|
|
@ -160,6 +166,7 @@ public class CommandContext<C> {
|
||||||
* @return Command sender
|
* @return Command sender
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
public boolean hasPermission(final @NonNull CommandPermission permission) {
|
public boolean hasPermission(final @NonNull CommandPermission permission) {
|
||||||
return this.commandManager.hasPermission(this.commandSender, permission);
|
return this.commandManager.hasPermission(this.commandSender, permission);
|
||||||
}
|
}
|
||||||
|
|
@ -171,6 +178,7 @@ public class CommandContext<C> {
|
||||||
* @return Command sender
|
* @return Command sender
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
public boolean hasPermission(final @NonNull String permission) {
|
public boolean hasPermission(final @NonNull String permission) {
|
||||||
return this.commandManager.hasPermission(this.commandSender, permission);
|
return this.commandManager.hasPermission(this.commandSender, permission);
|
||||||
}
|
}
|
||||||
|
|
@ -229,6 +237,7 @@ public class CommandContext<C> {
|
||||||
* @param <T> Value type
|
* @param <T> Value type
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> void store(final @NonNull CloudKeyHolder<T> keyHolder, final @NonNull T value) {
|
public <T> void store(final @NonNull CloudKeyHolder<T> keyHolder, final @NonNull T value) {
|
||||||
this.internalStorage.put(keyHolder.getKey(), value);
|
this.internalStorage.put(keyHolder.getKey(), value);
|
||||||
}
|
}
|
||||||
|
|
@ -244,6 +253,7 @@ public class CommandContext<C> {
|
||||||
* @param <T> Value type
|
* @param <T> Value type
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public <T> void set(final @NonNull String key, final @Nullable T value) {
|
public <T> void set(final @NonNull String key, final @Nullable T value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
this.store(key, value);
|
this.store(key, value);
|
||||||
|
|
@ -263,6 +273,7 @@ public class CommandContext<C> {
|
||||||
* @param <T> Value type
|
* @param <T> Value type
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> void set(final @NonNull CloudKey<T> key, final @Nullable T value) {
|
public <T> void set(final @NonNull CloudKey<T> key, final @Nullable T value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
this.store(key, value);
|
this.store(key, value);
|
||||||
|
|
@ -278,6 +289,7 @@ public class CommandContext<C> {
|
||||||
* @return Whether the context has a value for the provided key
|
* @return Whether the context has a value for the provided key
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public boolean contains(final @NonNull String key) {
|
public boolean contains(final @NonNull String key) {
|
||||||
return this.contains(SimpleCloudKey.of(key));
|
return this.contains(SimpleCloudKey.of(key));
|
||||||
}
|
}
|
||||||
|
|
@ -289,6 +301,7 @@ public class CommandContext<C> {
|
||||||
* @return Whether the context has a value for the provided key
|
* @return Whether the context has a value for the provided key
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public boolean contains(final @NonNull CloudKey<?> key) {
|
public boolean contains(final @NonNull CloudKey<?> key) {
|
||||||
return this.internalStorage.containsKey(key);
|
return this.internalStorage.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
@ -299,6 +312,7 @@ public class CommandContext<C> {
|
||||||
* @return An immutable copy of this command context as a map
|
* @return An immutable copy of this command context as a map
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public @NonNull Map<@NonNull String, @Nullable ?> asMap() {
|
public @NonNull Map<@NonNull String, @Nullable ?> asMap() {
|
||||||
final Map<String, Object> values = new HashMap<>();
|
final Map<String, Object> values = new HashMap<>();
|
||||||
this.internalStorage.forEach((key, value) -> values.put(key.getName(), value));
|
this.internalStorage.forEach((key, value) -> values.put(key.getName(), value));
|
||||||
|
|
@ -332,6 +346,7 @@ public class CommandContext<C> {
|
||||||
* @return Value
|
* @return Value
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @NonNull Optional<T> getOptional(final @NonNull CloudKey<T> key) {
|
public <T> @NonNull Optional<T> getOptional(final @NonNull CloudKey<T> key) {
|
||||||
final Object value = this.internalStorage.get(key);
|
final Object value = this.internalStorage.get(key);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
|
@ -365,6 +380,7 @@ public class CommandContext<C> {
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @NonNull Optional<T> getOptional(final @NonNull CloudKeyHolder<T> keyHolder) {
|
public <T> @NonNull Optional<T> getOptional(final @NonNull CloudKeyHolder<T> keyHolder) {
|
||||||
final Object value = this.internalStorage.get(keyHolder.getKey());
|
final Object value = this.internalStorage.get(keyHolder.getKey());
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
|
@ -390,6 +406,7 @@ public class CommandContext<C> {
|
||||||
* @param key Key to remove
|
* @param key Key to remove
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public void remove(final @NonNull CloudKey<?> key) {
|
public void remove(final @NonNull CloudKey<?> key) {
|
||||||
this.internalStorage.remove(key);
|
this.internalStorage.remove(key);
|
||||||
}
|
}
|
||||||
|
|
@ -423,6 +440,7 @@ public class CommandContext<C> {
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @NonNull T get(final @NonNull CloudKey<T> key) {
|
public <T> @NonNull T get(final @NonNull CloudKey<T> key) {
|
||||||
final Object value = this.internalStorage.get(key);
|
final Object value = this.internalStorage.get(key);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
@ -454,6 +472,7 @@ public class CommandContext<C> {
|
||||||
* @throws NullPointerException If no such value is stored
|
* @throws NullPointerException If no such value is stored
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @NonNull T get(final @NonNull CloudKeyHolder<T> keyHolder) {
|
public <T> @NonNull T get(final @NonNull CloudKeyHolder<T> keyHolder) {
|
||||||
return this.get(keyHolder.getKey());
|
return this.get(keyHolder.getKey());
|
||||||
}
|
}
|
||||||
|
|
@ -497,6 +516,7 @@ public class CommandContext<C> {
|
||||||
* @return Argument, or supplied default value
|
* @return Argument, or supplied default value
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @Nullable T getOrDefault(
|
public <T> @Nullable T getOrDefault(
|
||||||
final @NonNull CloudKey<T> key,
|
final @NonNull CloudKey<T> key,
|
||||||
final @Nullable T defaultValue
|
final @Nullable T defaultValue
|
||||||
|
|
@ -513,6 +533,7 @@ public class CommandContext<C> {
|
||||||
* @return Argument, or supplied default value
|
* @return Argument, or supplied default value
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public <T> @Nullable T getOrSupplyDefault(
|
public <T> @Nullable T getOrSupplyDefault(
|
||||||
final @NonNull String key,
|
final @NonNull String key,
|
||||||
final @NonNull Supplier<@Nullable T> defaultSupplier
|
final @NonNull Supplier<@Nullable T> defaultSupplier
|
||||||
|
|
@ -529,6 +550,7 @@ public class CommandContext<C> {
|
||||||
* @return Argument, or supplied default value
|
* @return Argument, or supplied default value
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public <T> @Nullable T getOrSupplyDefault(
|
public <T> @Nullable T getOrSupplyDefault(
|
||||||
final @NonNull CloudKey<T> key,
|
final @NonNull CloudKey<T> key,
|
||||||
final @NonNull Supplier<@Nullable T> defaultSupplier
|
final @NonNull Supplier<@Nullable T> defaultSupplier
|
||||||
|
|
@ -551,6 +573,7 @@ public class CommandContext<C> {
|
||||||
* @return {@link #getRawInput()} joined with {@code " "} as the delimiter
|
* @return {@link #getRawInput()} joined with {@code " "} as the delimiter
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.1.0")
|
||||||
public @NonNull String getRawInputJoined() {
|
public @NonNull String getRawInputJoined() {
|
||||||
return String.join(" ", this.getRawInput());
|
return String.join(" ", this.getRawInput());
|
||||||
}
|
}
|
||||||
|
|
@ -593,6 +616,7 @@ public class CommandContext<C> {
|
||||||
* @return Currently parsing {@link CommandArgument} or {@code null}
|
* @return Currently parsing {@link CommandArgument} or {@code null}
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public @Nullable CommandArgument<C, ?> getCurrentArgument() {
|
public @Nullable CommandArgument<C, ?> getCurrentArgument() {
|
||||||
return this.currentArgument;
|
return this.currentArgument;
|
||||||
}
|
}
|
||||||
|
|
@ -605,6 +629,7 @@ public class CommandContext<C> {
|
||||||
* @param argument Currently parsing {@link CommandArgument} or {@code null}
|
* @param argument Currently parsing {@link CommandArgument} or {@code null}
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public void setCurrentArgument(final @Nullable CommandArgument<C, ?> argument) {
|
public void setCurrentArgument(final @Nullable CommandArgument<C, ?> argument) {
|
||||||
this.currentArgument = argument;
|
this.currentArgument = argument;
|
||||||
}
|
}
|
||||||
|
|
@ -618,7 +643,7 @@ public class CommandContext<C> {
|
||||||
* @return Optional that may contain the created value
|
* @return Optional that may contain the created value
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public <@NonNull T> @NonNull Optional<T> inject(final @NonNull Class<T> clazz) {
|
public <@NonNull T> @NonNull Optional<T> inject(final @NonNull Class<T> clazz) {
|
||||||
if (this.commandManager == null) {
|
if (this.commandManager == null) {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
|
|
@ -636,6 +661,7 @@ public class CommandContext<C> {
|
||||||
* <p>
|
* <p>
|
||||||
* The times are measured in nanoseconds.
|
* The times are measured in nanoseconds.
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class ArgumentTiming {
|
public static final class ArgumentTiming {
|
||||||
|
|
||||||
private long start;
|
private long start;
|
||||||
|
|
@ -647,7 +673,7 @@ public class CommandContext<C> {
|
||||||
*
|
*
|
||||||
* @param start Start time (in nanoseconds)
|
* @param start Start time (in nanoseconds)
|
||||||
* @param end End time (in nanoseconds)
|
* @param end End time (in nanoseconds)
|
||||||
* @param success Whether or not the argument was parsed successfully
|
* @param success Whether the argument was parsed successfully
|
||||||
*/
|
*/
|
||||||
public ArgumentTiming(final long start, final long end, final boolean success) {
|
public ArgumentTiming(final long start, final long end, final boolean success) {
|
||||||
this.start = start;
|
this.start = start;
|
||||||
|
|
@ -690,7 +716,7 @@ public class CommandContext<C> {
|
||||||
* Set the end time
|
* Set the end time
|
||||||
*
|
*
|
||||||
* @param end End time (in nanoseconds)
|
* @param end End time (in nanoseconds)
|
||||||
* @param success Whether or not the argument was parsed successfully
|
* @param success Whether the argument was parsed successfully
|
||||||
*/
|
*/
|
||||||
public void setEnd(final long end, final boolean success) {
|
public void setEnd(final long end, final boolean success) {
|
||||||
this.end = end;
|
this.end = end;
|
||||||
|
|
@ -707,7 +733,7 @@ public class CommandContext<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether or not the value was parsed successfully
|
* Check whether the value was parsed successfully
|
||||||
*
|
*
|
||||||
* @return {@code true} if the value was parsed successfully, {@code false} if not
|
* @return {@code true} if the value was parsed successfully, {@code false} if not
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.context;
|
||||||
|
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
import cloud.commandframework.captions.CaptionRegistry;
|
import cloud.commandframework.captions.CaptionRegistry;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender
|
* @param <C> Command sender
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CommandContextFactory<C> {
|
public interface CommandContextFactory<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,6 +46,7 @@ public interface CommandContextFactory<C> {
|
||||||
* @deprecated Provide a command manager instead of a caption registry
|
* @deprecated Provide a command manager instead of a caption registry
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@API(status = API.Status.DEPRECATED, since = "1.3.0")
|
||||||
@NonNull CommandContext<C> create(
|
@NonNull CommandContext<C> create(
|
||||||
boolean suggestions,
|
boolean suggestions,
|
||||||
@NonNull C sender,
|
@NonNull C sender,
|
||||||
|
|
@ -59,6 +62,7 @@ public interface CommandContextFactory<C> {
|
||||||
* @return Command context
|
* @return Command context
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
@NonNull CommandContext<C> create(
|
@NonNull CommandContext<C> create(
|
||||||
boolean suggestions,
|
boolean suggestions,
|
||||||
@NonNull C sender,
|
@NonNull C sender,
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,11 @@ package cloud.commandframework.context;
|
||||||
|
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
import cloud.commandframework.captions.CaptionRegistry;
|
import cloud.commandframework.captions.CaptionRegistry;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public final class StandardCommandContextFactory<C> implements CommandContextFactory<C> {
|
public final class StandardCommandContextFactory<C> implements CommandContextFactory<C> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -37,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* is detected.
|
* is detected.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "serial"})
|
@SuppressWarnings({"unused", "serial"})
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class AmbiguousNodeException extends IllegalStateException {
|
public final class AmbiguousNodeException extends IllegalStateException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -200207173805584709L;
|
private static final long serialVersionUID = -200207173805584709L;
|
||||||
|
|
@ -51,6 +53,7 @@ public final class AmbiguousNodeException extends IllegalStateException {
|
||||||
* @param ambiguousNode Node that caused exception
|
* @param ambiguousNode Node that caused exception
|
||||||
* @param children All children of the parent
|
* @param children All children of the parent
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public AmbiguousNodeException(
|
public AmbiguousNodeException(
|
||||||
final @Nullable CommandArgument<?, ?> parentNode,
|
final @Nullable CommandArgument<?, ?> parentNode,
|
||||||
final @NonNull CommandArgument<?, ?> ambiguousNode,
|
final @NonNull CommandArgument<?, ?> ambiguousNode,
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,10 @@ package cloud.commandframework.exceptions;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class ArgumentParseException extends CommandParseException {
|
public class ArgumentParseException extends CommandParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -4385446899439587461L;
|
private static final long serialVersionUID = -4385446899439587461L;
|
||||||
|
|
@ -39,6 +41,7 @@ public class ArgumentParseException extends CommandParseException {
|
||||||
* @param commandSender Command sender
|
* @param commandSender Command sender
|
||||||
* @param currentChain Chain leading up to the exception
|
* @param currentChain Chain leading up to the exception
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public ArgumentParseException(
|
public ArgumentParseException(
|
||||||
final @NonNull Throwable throwable,
|
final @NonNull Throwable throwable,
|
||||||
final @NonNull Object commandSender,
|
final @NonNull Object commandSender,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework.exceptions;
|
package cloud.commandframework.exceptions;
|
||||||
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE, since = "1.2.0")
|
||||||
public class CommandExecutionException extends IllegalArgumentException {
|
public class CommandExecutionException extends IllegalArgumentException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -4785446899438294661L;
|
private static final long serialVersionUID = -4785446899438294661L;
|
||||||
|
|
@ -43,6 +45,7 @@ public class CommandExecutionException extends IllegalArgumentException {
|
||||||
*
|
*
|
||||||
* @param cause Exception thrown during the execution of a command handler
|
* @param cause Exception thrown during the execution of a command handler
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public CommandExecutionException(final @NonNull Throwable cause) {
|
public CommandExecutionException(final @NonNull Throwable cause) {
|
||||||
this(cause, null);
|
this(cause, null);
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +57,7 @@ public class CommandExecutionException extends IllegalArgumentException {
|
||||||
* @param commandContext Command context
|
* @param commandContext Command context
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*", since = "1.4.0")
|
||||||
public CommandExecutionException(final @NonNull Throwable cause, final @Nullable CommandContext<?> commandContext) {
|
public CommandExecutionException(final @NonNull Throwable cause, final @Nullable CommandContext<?> commandContext) {
|
||||||
super(cause);
|
super(cause);
|
||||||
this.commandContext = commandContext;
|
this.commandContext = commandContext;
|
||||||
|
|
@ -65,6 +69,7 @@ public class CommandExecutionException extends IllegalArgumentException {
|
||||||
* @return Command
|
* @return Command
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public @Nullable CommandContext<?> getCommandContext() {
|
public @Nullable CommandContext<?> getCommandContext() {
|
||||||
return this.commandContext;
|
return this.commandContext;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,14 @@ package cloud.commandframework.exceptions;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when parsing user input into a command
|
* Exception thrown when parsing user input into a command
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "serial"})
|
@SuppressWarnings({"unused", "serial"})
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class CommandParseException extends IllegalArgumentException {
|
public class CommandParseException extends IllegalArgumentException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2415981126382517435L;
|
private static final long serialVersionUID = -2415981126382517435L;
|
||||||
|
|
@ -44,6 +46,7 @@ public class CommandParseException extends IllegalArgumentException {
|
||||||
* @param commandSender Sender who executed the command
|
* @param commandSender Sender who executed the command
|
||||||
* @param currentChain Chain leading up to the exception
|
* @param currentChain Chain leading up to the exception
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
protected CommandParseException(
|
protected CommandParseException(
|
||||||
final @NonNull Object commandSender,
|
final @NonNull Object commandSender,
|
||||||
final @NonNull List<CommandArgument<?, ?>> currentChain
|
final @NonNull List<CommandArgument<?, ?>> currentChain
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ package cloud.commandframework.exceptions;
|
||||||
import cloud.commandframework.Command;
|
import cloud.commandframework.Command;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* Exception thrown when an invalid command sender tries to execute a command
|
* Exception thrown when an invalid command sender tries to execute a command
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class InvalidCommandSenderException extends CommandParseException {
|
public final class InvalidCommandSenderException extends CommandParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7372142477529875598L;
|
private static final long serialVersionUID = 7372142477529875598L;
|
||||||
|
|
@ -46,6 +48,7 @@ public final class InvalidCommandSenderException extends CommandParseException {
|
||||||
* @param requiredSender The sender type that is required
|
* @param requiredSender The sender type that is required
|
||||||
* @param currentChain Chain leading up to the exception
|
* @param currentChain Chain leading up to the exception
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public InvalidCommandSenderException(
|
public InvalidCommandSenderException(
|
||||||
final @NonNull Object commandSender,
|
final @NonNull Object commandSender,
|
||||||
final @NonNull Class<?> requiredSender,
|
final @NonNull Class<?> requiredSender,
|
||||||
|
|
@ -63,6 +66,7 @@ public final class InvalidCommandSenderException extends CommandParseException {
|
||||||
* @param command Command
|
* @param command Command
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*", since = "1.4.0")
|
||||||
public InvalidCommandSenderException(
|
public InvalidCommandSenderException(
|
||||||
final @NonNull Object commandSender,
|
final @NonNull Object commandSender,
|
||||||
final @NonNull Class<?> requiredSender,
|
final @NonNull Class<?> requiredSender,
|
||||||
|
|
@ -98,6 +102,7 @@ public final class InvalidCommandSenderException extends CommandParseException {
|
||||||
* @return Command
|
* @return Command
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public @Nullable Command<?> getCommand() {
|
public @Nullable Command<?> getCommand() {
|
||||||
return this.command;
|
return this.command;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,14 @@ package cloud.commandframework.exceptions;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception sent when a command sender inputs invalid command syntax
|
* Exception sent when a command sender inputs invalid command syntax
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class InvalidSyntaxException extends CommandParseException {
|
public class InvalidSyntaxException extends CommandParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -4183356059293785202L;
|
private static final long serialVersionUID = -4183356059293785202L;
|
||||||
|
|
@ -43,6 +45,7 @@ public class InvalidSyntaxException extends CommandParseException {
|
||||||
* @param commandSender Sender that sent the command
|
* @param commandSender Sender that sent the command
|
||||||
* @param currentChain Chain leading up to issue
|
* @param currentChain Chain leading up to issue
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public InvalidSyntaxException(
|
public InvalidSyntaxException(
|
||||||
final @NonNull String correctSyntax,
|
final @NonNull String correctSyntax,
|
||||||
final @NonNull Object commandSender,
|
final @NonNull Object commandSender,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.exceptions;
|
||||||
|
|
||||||
import cloud.commandframework.Command;
|
import cloud.commandframework.Command;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* that is registered as a leaf node, does not contain an owning {@link Command}
|
* that is registered as a leaf node, does not contain an owning {@link Command}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "serial"})
|
@SuppressWarnings({"unused", "serial"})
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class NoCommandInLeafException extends IllegalStateException {
|
public final class NoCommandInLeafException extends IllegalStateException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3373529875213310821L;
|
private static final long serialVersionUID = 3373529875213310821L;
|
||||||
|
|
@ -42,6 +44,7 @@ public final class NoCommandInLeafException extends IllegalStateException {
|
||||||
*
|
*
|
||||||
* @param commandArgument Command argument that caused the exception
|
* @param commandArgument Command argument that caused the exception
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public NoCommandInLeafException(final @NonNull CommandArgument<?, ?> commandArgument) {
|
public NoCommandInLeafException(final @NonNull CommandArgument<?, ?> commandArgument) {
|
||||||
super(String.format("Leaf node '%s' does not have associated owning command", commandArgument.getName()));
|
super(String.format("Leaf node '%s' does not have associated owning command", commandArgument.getName()));
|
||||||
this.commandArgument = commandArgument;
|
this.commandArgument = commandArgument;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.Command;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import cloud.commandframework.permission.CommandPermission;
|
import cloud.commandframework.permission.CommandPermission;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -34,6 +35,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* to execute a {@link Command}
|
* to execute a {@link Command}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "serial"})
|
@SuppressWarnings({"unused", "serial"})
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class NoPermissionException extends CommandParseException {
|
public class NoPermissionException extends CommandParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7103413337750692843L;
|
private static final long serialVersionUID = 7103413337750692843L;
|
||||||
|
|
@ -46,6 +48,7 @@ public class NoPermissionException extends CommandParseException {
|
||||||
* @param commandSender Command sender
|
* @param commandSender Command sender
|
||||||
* @param currentChain Chain leading up to the exception
|
* @param currentChain Chain leading up to the exception
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public NoPermissionException(
|
public NoPermissionException(
|
||||||
final @NonNull CommandPermission missingPermission,
|
final @NonNull CommandPermission missingPermission,
|
||||||
final @NonNull Object commandSender,
|
final @NonNull Object commandSender,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.exceptions;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* a command that doesn't exist
|
* a command that doesn't exist
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class NoSuchCommandException extends CommandParseException {
|
public final class NoSuchCommandException extends CommandParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -7775865652882764771L;
|
private static final long serialVersionUID = -7775865652882764771L;
|
||||||
|
|
@ -44,6 +46,7 @@ public final class NoSuchCommandException extends CommandParseException {
|
||||||
* @param currentChain Chain leading up to the exception
|
* @param currentChain Chain leading up to the exception
|
||||||
* @param command Entered command (following the command chain)
|
* @param command Entered command (following the command chain)
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public NoSuchCommandException(
|
public NoSuchCommandException(
|
||||||
final @NonNull Object commandSender,
|
final @NonNull Object commandSender,
|
||||||
final @NonNull List<CommandArgument<?, ?>> currentChain,
|
final @NonNull List<CommandArgument<?, ?>> currentChain,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.exceptions.parsing;
|
||||||
|
|
||||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.1.0")
|
||||||
public class NoInputProvidedException extends ParserException {
|
public class NoInputProvidedException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3485754951593709559L;
|
private static final long serialVersionUID = 3485754951593709559L;
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,10 @@ package cloud.commandframework.exceptions.parsing;
|
||||||
import cloud.commandframework.captions.CaptionVariable;
|
import cloud.commandframework.captions.CaptionVariable;
|
||||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public abstract class NumberParseException extends ParserException {
|
public abstract class NumberParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3018775374056029797L;
|
private static final long serialVersionUID = 3018775374056029797L;
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,11 @@ import cloud.commandframework.captions.Caption;
|
||||||
import cloud.commandframework.captions.CaptionVariable;
|
import cloud.commandframework.captions.CaptionVariable;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class ParserException extends IllegalArgumentException {
|
public class ParserException extends IllegalArgumentException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -4409795575435072170L;
|
private static final long serialVersionUID = -4409795575435072170L;
|
||||||
|
|
@ -64,6 +66,7 @@ public class ParserException extends IllegalArgumentException {
|
||||||
* @return The caption
|
* @return The caption
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public @NonNull Caption errorCaption() {
|
public @NonNull Caption errorCaption() {
|
||||||
return this.errorCaption;
|
return this.errorCaption;
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +78,7 @@ public class ParserException extends IllegalArgumentException {
|
||||||
* @return The caption variables
|
* @return The caption variables
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public @NonNull CaptionVariable @NonNull [] captionVariables() {
|
public @NonNull CaptionVariable @NonNull [] captionVariables() {
|
||||||
return Arrays.copyOf(this.captionVariables, this.captionVariables.length);
|
return Arrays.copyOf(this.captionVariables, this.captionVariables.length);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
@ -45,6 +46,7 @@ import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class AsynchronousCommandExecutionCoordinator<C> extends CommandExecutionCoordinator<C> {
|
public final class AsynchronousCommandExecutionCoordinator<C> extends CommandExecutionCoordinator<C> {
|
||||||
|
|
||||||
private final CommandManager<C> commandManager;
|
private final CommandManager<C> commandManager;
|
||||||
|
|
@ -128,6 +130,7 @@ public final class AsynchronousCommandExecutionCoordinator<C> extends CommandExe
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public static final class Builder<C> {
|
public static final class Builder<C> {
|
||||||
|
|
||||||
private Executor executor = null;
|
private Executor executor = null;
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
|
@ -44,6 +45,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public abstract class CommandExecutionCoordinator<C> {
|
public abstract class CommandExecutionCoordinator<C> {
|
||||||
|
|
||||||
private final CommandTree<C> commandTree;
|
private final CommandTree<C> commandTree;
|
||||||
|
|
@ -95,6 +97,7 @@ public abstract class CommandExecutionCoordinator<C> {
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public static final class SimpleCoordinator<C> extends
|
public static final class SimpleCoordinator<C> extends
|
||||||
CommandExecutionCoordinator<C> {
|
CommandExecutionCoordinator<C> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
@ -39,6 +40,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CommandExecutionHandler<C> {
|
public interface CommandExecutionHandler<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,6 +50,7 @@ public interface CommandExecutionHandler<C> {
|
||||||
* @return command execution handler that does nothing
|
* @return command execution handler that does nothing
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
static <C> @NonNull CommandExecutionHandler<C> noOpCommandExecutionHandler() {
|
static <C> @NonNull CommandExecutionHandler<C> noOpCommandExecutionHandler() {
|
||||||
return new NullCommandExecutionHandler<>();
|
return new NullCommandExecutionHandler<>();
|
||||||
}
|
}
|
||||||
|
|
@ -64,6 +67,7 @@ public interface CommandExecutionHandler<C> {
|
||||||
* @return multicast-delegate command execution handler
|
* @return multicast-delegate command execution handler
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.7.0")
|
||||||
static <C> @NonNull CommandExecutionHandler<C> delegatingExecutionHandler(
|
static <C> @NonNull CommandExecutionHandler<C> delegatingExecutionHandler(
|
||||||
final List<CommandExecutionHandler<C>> handlers
|
final List<CommandExecutionHandler<C>> handlers
|
||||||
) {
|
) {
|
||||||
|
|
@ -84,6 +88,7 @@ public interface CommandExecutionHandler<C> {
|
||||||
* @return future that completes when the command has finished execution
|
* @return future that completes when the command has finished execution
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
default CompletableFuture<@Nullable Void> executeFuture(@NonNull CommandContext<C> commandContext) {
|
default CompletableFuture<@Nullable Void> executeFuture(@NonNull CommandContext<C> commandContext) {
|
||||||
final CompletableFuture<Void> future = new CompletableFuture<>();
|
final CompletableFuture<Void> future = new CompletableFuture<>();
|
||||||
try {
|
try {
|
||||||
|
|
@ -101,6 +106,7 @@ public interface CommandExecutionHandler<C> {
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
class NullCommandExecutionHandler<C> implements CommandExecutionHandler<C> {
|
class NullCommandExecutionHandler<C> implements CommandExecutionHandler<C> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -117,6 +123,7 @@ public interface CommandExecutionHandler<C> {
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@API(status = API.Status.STABLE, since = "1.6.0")
|
||||||
interface FutureCommandExecutionHandler<C> extends CommandExecutionHandler<C> {
|
interface FutureCommandExecutionHandler<C> extends CommandExecutionHandler<C> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -140,6 +147,7 @@ public interface CommandExecutionHandler<C> {
|
||||||
* @see #delegatingExecutionHandler(List)
|
* @see #delegatingExecutionHandler(List)
|
||||||
* @since 1.7.0
|
* @since 1.7.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*", since = "1.7.0")
|
||||||
final class MulticastDelegateFutureCommandExecutionHandler<C> implements FutureCommandExecutionHandler<C> {
|
final class MulticastDelegateFutureCommandExecutionHandler<C> implements FutureCommandExecutionHandler<C> {
|
||||||
|
|
||||||
private final List<CommandExecutionHandler<C>> handlers;
|
private final List<CommandExecutionHandler<C>> handlers;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework.execution;
|
package cloud.commandframework.execution;
|
||||||
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class CommandResult<C> {
|
public class CommandResult<C> {
|
||||||
|
|
||||||
private final CommandContext<C> commandContext;
|
private final CommandContext<C> commandContext;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ package cloud.commandframework.execution;
|
||||||
import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext;
|
import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CommandSuggestionProcessor<C> extends
|
public interface CommandSuggestionProcessor<C> extends
|
||||||
BiFunction<@NonNull CommandPreprocessingContext<C>, @NonNull List<String>, @NonNull List<String>> {
|
BiFunction<@NonNull CommandPreprocessingContext<C>, @NonNull List<String>, @NonNull List<String>> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,15 @@ package cloud.commandframework.execution;
|
||||||
import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext;
|
import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command suggestions processor that checks the input queue head and filters based on that
|
* Command suggestion processor that checks the input queue head and filters based on that
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class FilteringCommandSuggestionProcessor<C> implements CommandSuggestionProcessor<C> {
|
public final class FilteringCommandSuggestionProcessor<C> implements CommandSuggestionProcessor<C> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
//
|
//
|
||||||
package cloud.commandframework.execution.postprocessor;
|
package cloud.commandframework.execution.postprocessor;
|
||||||
|
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public final class AcceptingCommandPostprocessor<C> implements CommandPostprocessor<C> {
|
public final class AcceptingCommandPostprocessor<C> implements CommandPostprocessor<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ package cloud.commandframework.execution.postprocessor;
|
||||||
import cloud.commandframework.Command;
|
import cloud.commandframework.Command;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class CommandPostprocessingContext<C> {
|
public final class CommandPostprocessingContext<C> {
|
||||||
|
|
||||||
private final CommandContext<@NonNull C> commandContext;
|
private final CommandContext<@NonNull C> commandContext;
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,14 @@
|
||||||
package cloud.commandframework.execution.postprocessor;
|
package cloud.commandframework.execution.postprocessor;
|
||||||
|
|
||||||
import cloud.commandframework.services.types.ConsumerService;
|
import cloud.commandframework.services.types.ConsumerService;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command postprocessor that acts on commands before execution
|
* Command postprocessor that acts on commands before execution
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CommandPostprocessor<C> extends ConsumerService<CommandPostprocessingContext<C>> {
|
public interface CommandPostprocessor<C> extends ConsumerService<CommandPostprocessingContext<C>> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
//
|
//
|
||||||
package cloud.commandframework.execution.preprocessor;
|
package cloud.commandframework.execution.preprocessor;
|
||||||
|
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public final class AcceptingCommandPreprocessor<C> implements CommandPreprocessor<C> {
|
public final class AcceptingCommandPreprocessor<C> implements CommandPreprocessor<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ package cloud.commandframework.execution.preprocessor;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public final class CommandPreprocessingContext<C> {
|
public final class CommandPreprocessingContext<C> {
|
||||||
|
|
||||||
private final CommandContext<C> commandContext;
|
private final CommandContext<C> commandContext;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework.execution.preprocessor;
|
package cloud.commandframework.execution.preprocessor;
|
||||||
|
|
||||||
import cloud.commandframework.services.types.ConsumerService;
|
import cloud.commandframework.services.types.ConsumerService;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command preprocessor that gets to act on command input
|
* Command preprocessor that gets to act on command input
|
||||||
|
|
@ -34,6 +35,7 @@ import cloud.commandframework.services.types.ConsumerService;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CommandPreprocessor<C> extends ConsumerService<CommandPreprocessingContext<C>> {
|
public interface CommandPreprocessor<C> extends ConsumerService<CommandPreprocessingContext<C>> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,6 +52,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public class CommandConfirmationManager<C> {
|
public class CommandConfirmationManager<C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -71,6 +73,7 @@ public class CommandConfirmationManager<C> {
|
||||||
*
|
*
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.3.0")
|
||||||
public static final CommandMeta.Key<Boolean> META_CONFIRMATION_REQUIRED = CommandMeta.Key.of(
|
public static final CommandMeta.Key<Boolean> META_CONFIRMATION_REQUIRED = CommandMeta.Key.of(
|
||||||
Boolean.class,
|
Boolean.class,
|
||||||
"cloud:require_confirmation",
|
"cloud:require_confirmation",
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ package cloud.commandframework.internal;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* at every blank space. If the input string ends with a blank space, a trailing
|
* at every blank space. If the input string ends with a blank space, a trailing
|
||||||
* empty string will be added to the token list
|
* empty string will be added to the token list
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
public final class CommandInputTokenizer {
|
public final class CommandInputTokenizer {
|
||||||
|
|
||||||
private static final String DELIMITER = " ";
|
private static final String DELIMITER = " ";
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework.internal;
|
package cloud.commandframework.internal;
|
||||||
|
|
||||||
import cloud.commandframework.Command;
|
import cloud.commandframework.Command;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* the target platform does not have its own concept of commands
|
* the target platform does not have its own concept of commands
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@API(status = API.Status.STABLE)
|
||||||
public interface CommandRegistrationHandler {
|
public interface CommandRegistrationHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,6 +54,8 @@ public interface CommandRegistrationHandler {
|
||||||
*/
|
*/
|
||||||
boolean registerCommand(@NonNull Command<?> command);
|
boolean registerCommand(@NonNull Command<?> command);
|
||||||
|
|
||||||
|
|
||||||
|
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
|
||||||
final class NullCommandRegistrationHandler implements CommandRegistrationHandler {
|
final class NullCommandRegistrationHandler implements CommandRegistrationHandler {
|
||||||
|
|
||||||
private NullCommandRegistrationHandler() {
|
private NullCommandRegistrationHandler() {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework.keys;
|
package cloud.commandframework.keys;
|
||||||
|
|
||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @param <T> The type of the key
|
* @param <T> The type of the key
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public interface CloudKey<T> {
|
public interface CloudKey<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
//
|
//
|
||||||
package cloud.commandframework.keys;
|
package cloud.commandframework.keys;
|
||||||
|
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@API(status = API.Status.STABLE, since = "1.4.0")
|
||||||
public interface CloudKeyHolder<T> {
|
public interface CloudKeyHolder<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue