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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <A extends revxrsal.commands.command.CommandActor>
    revxrsal.commands.node.FailureHandler<A>
    Returns the shared singleton instance of this handler.
    void
    handleFailedAttempts(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 FailureHandler instance
    • 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 an ExpectedLiteralException, 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:
      handleFailedAttempts in interface revxrsal.commands.node.FailureHandler<A extends revxrsal.commands.command.CommandActor>