✨ Add a method to get the failure reason of SelectorParseExceptions
This commit is contained in:
parent
a04e3f92cb
commit
e6af4e6caa
5 changed files with 18 additions and 4 deletions
|
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Added parameter injectors
|
- Added parameter injectors
|
||||||
- Store currently parsing command argument in the command context
|
- Store currently parsing command argument in the command context
|
||||||
- Added a method to CloudBrigadierManager to enable or disable Brigadier native suggestions for specific argument types
|
- Added a method to CloudBrigadierManager to enable or disable Brigadier native suggestions for specific argument types
|
||||||
|
- Added a method to get the failure reason of SelectorParseExceptions
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Allow for use of `@Completions` annotation with argument types other than String
|
- Allow for use of `@Completions` annotation with argument types other than String
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.lang.annotation.Target;
|
||||||
* {@link cloud.commandframework.annotations.CommandMethod}
|
* {@link cloud.commandframework.annotations.CommandMethod}
|
||||||
* <p>
|
* <p>
|
||||||
* This should only be used on {@code String[]}
|
* This should only be used on {@code String[]}
|
||||||
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ public abstract class CommandManager<C> {
|
||||||
*
|
*
|
||||||
* @param name Command name
|
* @param name Command name
|
||||||
* @param aliases Command aliases
|
* @param aliases Command aliases
|
||||||
* @param description Command description
|
* @param description Description for the root literal
|
||||||
* @param meta Command meta
|
* @param meta Command meta
|
||||||
* @return Builder instance
|
* @return Builder instance
|
||||||
*/
|
*/
|
||||||
|
|
@ -394,7 +394,7 @@ public abstract class CommandManager<C> {
|
||||||
*
|
*
|
||||||
* @param name Command name
|
* @param name Command name
|
||||||
* @param meta Command meta
|
* @param meta Command meta
|
||||||
* @param description Command description
|
* @param description Description for the root literal
|
||||||
* @param aliases Command aliases
|
* @param aliases Command aliases
|
||||||
* @return Builder instance
|
* @return Builder instance
|
||||||
*/
|
*/
|
||||||
|
|
@ -455,7 +455,7 @@ public abstract class CommandManager<C> {
|
||||||
* {@link Command command} instance
|
* {@link Command command} instance
|
||||||
*
|
*
|
||||||
* @param name Command name
|
* @param name Command name
|
||||||
* @param description Command description
|
* @param description Description for the root literal
|
||||||
* @param aliases Command aliases
|
* @param aliases Command aliases
|
||||||
* @return Builder instance
|
* @return Builder instance
|
||||||
* @throws UnsupportedOperationException If the command manager does not support default command meta creation
|
* @throws UnsupportedOperationException If the command manager does not support default command meta creation
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class ParserException extends IllegalArgumentException {
|
||||||
private final CaptionVariable[] captionVariables;
|
private final CaptionVariable[] captionVariables;
|
||||||
|
|
||||||
protected ParserException(
|
protected ParserException(
|
||||||
final Class<?> argumentParser,
|
final @NonNull Class<?> argumentParser,
|
||||||
final @NonNull CommandContext<?> context,
|
final @NonNull CommandContext<?> context,
|
||||||
final @NonNull Caption errorCaption,
|
final @NonNull Caption errorCaption,
|
||||||
final @NonNull CaptionVariable... captionVariables
|
final @NonNull CaptionVariable... captionVariables
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public final class SelectorParseException extends ParserException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1900826717897819065L;
|
private static final long serialVersionUID = 1900826717897819065L;
|
||||||
private final String input;
|
private final String input;
|
||||||
|
private final FailureReason reason;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new EntitySelector parse exception
|
* Construct a new EntitySelector parse exception
|
||||||
|
|
@ -58,6 +59,7 @@ public final class SelectorParseException extends ParserException {
|
||||||
reason.getCaption(),
|
reason.getCaption(),
|
||||||
CaptionVariable.of("input", input)
|
CaptionVariable.of("input", input)
|
||||||
);
|
);
|
||||||
|
this.reason = reason;
|
||||||
this.input = input;
|
this.input = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,6 +72,16 @@ public final class SelectorParseException extends ParserException {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the reason of failure for the selector parser
|
||||||
|
*
|
||||||
|
* @return Failure reason
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
public @NonNull FailureReason getFailureReason() {
|
||||||
|
return this.reason;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reasons for which selector parsing may fail
|
* Reasons for which selector parsing may fail
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue