🛖
Fox Hut
  • Introduction
    • Setting up
    • CommandActor, @Command and @Subcommand
    • Creating your first command
    • Improving our greet command
  • Platforms
    • Bukkit / Spigot / Paper
    • BungeeCord
    • Velocity
    • Sponge
    • Fabric
    • Brigadier
    • Minestom
    • JDA
    • Command line
  • How-to
    • Creating variants of /teleport
    • Custom parameter types
    • Suggestions and auto-completion
    • Context parameters
    • Command permissions
    • Parameter validators
    • Command conditions
    • Response handlers
    • Cooldowns
    • Help commands
    • Annotation replacers
    • Orphan command
    • Exception handling
    • Hooks
    • Dependency injection
    • Visitors
    • Customizing the dispatcher and failure behavior
Powered by GitBook
On this page
  • DispatcherSettings
  • Example

Was this helpful?

Edit on GitHub
  1. How-to

Customizing the dispatcher and failure behavior

Lamp's strategy for finding the best command is not fail-proof, and, because it relies on user input, it may not always be able to find the error cause spot on (simply put, it may not exist, or there may be many!)

Therefore, Lamp allows you to tweak the resolution strategy, and change the failure behavior. This is done using the DispatcherSettings class, which you can customize using Lamp.Builder#dispatcherSettings().

DispatcherSettings

The DispatcherSettings class allows you to customize the following:

  1. The maximum number of commands it should try

  2. The failure behavior that receives all the failed attempts (Potentials) and the user input. This is done using the FailureHandler interface.

Example

var builder = ...;
builder.dispatcherSettings(settings -> {
    settings.maximumFailedAttempts(10).failureHandler((actor, failedAttempts, input) -> {
        ...
    });
});
val builder = ...
builder.dispatcherSettings { settings ->
    settings.maximumFailedAttempts(10).failureHandler { actor, failedAttempts, input ->
    
    }
}
PreviousVisitors

Last updated 8 months ago

Was this helpful?