Package dev.demeng.pluginbase.command
Class BaseFailureHandler<A extends revxrsal.commands.command.CommandActor>
java.lang.Object
dev.demeng.pluginbase.command.BaseFailureHandler<A>
- All Implemented Interfaces:
revxrsal.commands.node.FailureHandler<A>
public final class BaseFailureHandler<A extends revxrsal.commands.command.CommandActor>
extends Object
implements revxrsal.commands.node.FailureHandler<A>
Custom failure handler for Lamp, to be set in dispatcher settings. Provides localized error
messages and best matches using PluginBase's utilities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <A extends revxrsal.commands.command.CommandActor>
revxrsal.commands.node.FailureHandler<A>Returns the shared singleton instance of this handler.voidhandleFailedAttempts(A actor, @NotNull @Unmodifiable List<revxrsal.commands.command.Potential<A>> failedAttempts, @NotNull revxrsal.commands.stream.StringStream input) Resolves which error to surface when one or more command attempts fail.
-
Constructor Details
-
BaseFailureHandler
public BaseFailureHandler()
-
-
Method Details
-
baseFailureHandler
public static <A extends revxrsal.commands.command.CommandActor> revxrsal.commands.node.FailureHandler<A> baseFailureHandler()Returns the shared singleton instance of this handler. The instance is stateless and safe to reuse across multiple dispatchers.- Returns:
- the shared
FailureHandlerinstance
-
handleFailedAttempts
public void handleFailedAttempts(@NotNull A actor, @NotNull @NotNull @Unmodifiable List<revxrsal.commands.command.Potential<A>> failedAttempts, @NotNull @NotNull revxrsal.commands.stream.StringStream input) Resolves which error to surface when one or more command attempts fail. If there is exactly one failure, its exception is re-thrown directly. If there are multiple failures and at least one is not anExpectedLiteralException, the first real exception is dispatched. If all failures are literal mismatches (i.e. no matching subcommand), a "did you mean X?" suggestion is sent to the actor using string similarity against the available command paths.Locale key for the suggestion message:
commands.failed-resolve- Specified by:
handleFailedAttemptsin interfacerevxrsal.commands.node.FailureHandler<A extends revxrsal.commands.command.CommandActor>
-