Class BaseExceptionHandler

java.lang.Object
revxrsal.commands.exception.RuntimeExceptionAdapter<A>
revxrsal.commands.exception.DefaultExceptionHandler<revxrsal.commands.bukkit.actor.BukkitCommandActor>
revxrsal.commands.bukkit.exception.BukkitExceptionHandler
dev.demeng.pluginbase.command.BaseExceptionHandler
All Implemented Interfaces:
revxrsal.commands.exception.CommandExceptionHandler<revxrsal.commands.bukkit.actor.BukkitCommandActor>

public class BaseExceptionHandler extends revxrsal.commands.bukkit.exception.BukkitExceptionHandler
Comprehensive exception handler for Lamp command framework, providing localized error messages using PluginBase's utilities. All error messages can be customized through locale files. See the "snippets" folder for a sample locale configuration.
  • Nested Class Summary

    Nested classes/interfaces inherited from class revxrsal.commands.exception.RuntimeExceptionAdapter

    revxrsal.commands.exception.RuntimeExceptionAdapter.HandleException
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onCommandInvocation(@NotNull revxrsal.commands.exception.CommandInvocationException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized internal error message and logs the underlying cause when command execution throws an unexpected exception.
    void
    onCooldown(@NotNull revxrsal.commands.exception.CooldownException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when a command is on cooldown, including the remaining wait time formatted with the concise duration formatter.
    void
    onEmptyEntitySelector(revxrsal.commands.bukkit.exception.EmptyEntitySelectorException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when an entity selector matches no entities.
    void
    onEnumNotFound(@NotNull revxrsal.commands.exception.EnumNotFoundException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when input does not match any enum constant.
    void
    onExpectedLiteral(@NotNull revxrsal.commands.exception.ExpectedLiteralException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when a literal node received unexpected input.
    void
    onInputParse(@NotNull revxrsal.commands.exception.InputParseException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message for input parsing failures.
    void
    onInvalidBoolean(@NotNull revxrsal.commands.exception.InvalidBooleanException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when input cannot be parsed as a boolean.
    void
    onInvalidDecimal(@NotNull revxrsal.commands.exception.InvalidDecimalException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when input cannot be parsed as a decimal number.
    void
    onInvalidHelpPage(@NotNull revxrsal.commands.exception.InvalidHelpPageException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message for an out-of-range help page number.
    void
    onInvalidInteger(@NotNull revxrsal.commands.exception.InvalidIntegerException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when input cannot be parsed as an integer.
    void
    onInvalidListSize(@NotNull revxrsal.commands.exception.InvalidListSizeException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor, @NotNull revxrsal.commands.node.ParameterNode<revxrsal.commands.bukkit.actor.BukkitCommandActor,?> parameter)
    Sends a localized error message when a list argument has too few or too many entries.
    void
    onInvalidPlayer(revxrsal.commands.bukkit.exception.InvalidPlayerException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message for invalid player input.
    void
    onInvalidStringSize(@NotNull revxrsal.commands.exception.InvalidStringSizeException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor, @NotNull revxrsal.commands.node.ParameterNode<revxrsal.commands.bukkit.actor.BukkitCommandActor,?> parameter)
    Sends a localized error message when a string argument is too short or too long.
    void
    onInvalidUUID(@NotNull revxrsal.commands.exception.InvalidUUIDException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when input cannot be parsed as a UUID.
    void
    onInvalidWorld(revxrsal.commands.bukkit.exception.InvalidWorldException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message for an invalid world name.
    void
    onInvalidWorld(revxrsal.commands.bukkit.exception.MissingLocationParameterException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when a required location axis parameter is missing.
    void
    onMalformedEntitySelector(revxrsal.commands.bukkit.exception.MalformedEntitySelectorException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message for a malformed entity selector.
    void
    onMissingArgument(@NotNull revxrsal.commands.exception.MissingArgumentException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor, @NotNull revxrsal.commands.node.ParameterNode<revxrsal.commands.bukkit.actor.BukkitCommandActor,?> parameter)
    Sends a localized error message when a required command argument is missing.
    void
    onMoreThanOneEntity(revxrsal.commands.bukkit.exception.MoreThanOneEntityException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when an entity selector matches more than one entity but only one is allowed.
    void
    onNonPlayerEntities(revxrsal.commands.bukkit.exception.NonPlayerEntitiesException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when an entity selector targets non-player entities but only players are allowed.
    void
    onNoPermission(@NotNull revxrsal.commands.exception.NoPermissionException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when the sender lacks permission to run the command.
    void
    onNumberNotInRange(@NotNull revxrsal.commands.exception.NumberNotInRangeException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor, @NotNull revxrsal.commands.node.ParameterNode<revxrsal.commands.bukkit.actor.BukkitCommandActor,Number> parameter)
    Sends a localized error message when a numeric argument falls outside its allowed range.
    void
    onSenderNotConsole(revxrsal.commands.bukkit.exception.SenderNotConsoleException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when a non-console sender runs a console-only command.
    void
    onSenderNotPlayer(revxrsal.commands.bukkit.exception.SenderNotPlayerException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when a non-player sender runs a player-only command.
    void
    onUnknownCommand(@NotNull revxrsal.commands.exception.UnknownCommandException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when the input does not match any known command.
    void
    onUnknownParameter(@NotNull revxrsal.commands.exception.UnknownParameterException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message for an unrecognized flag or shorthand parameter.
    void
    onValueNotAllowed(@NotNull revxrsal.commands.exception.ValueNotAllowedException e, @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
    Sends a localized error message when the provided value is not in the set of allowed values.

    Methods inherited from class revxrsal.commands.exception.DefaultExceptionHandler

    formatTimeFancy, onSendable, plural, toFancyString

    Methods inherited from class revxrsal.commands.exception.RuntimeExceptionAdapter

    fmt, handleException

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BaseExceptionHandler

      public BaseExceptionHandler()
  • Method Details

    • onInvalidPlayer

      public void onInvalidPlayer(revxrsal.commands.bukkit.exception.InvalidPlayerException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message for invalid player input.

      Locale key: commands.invalid-player

      Overrides:
      onInvalidPlayer in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidWorld

      public void onInvalidWorld(revxrsal.commands.bukkit.exception.InvalidWorldException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message for an invalid world name.

      Locale key: commands.invalid-world

      Overrides:
      onInvalidWorld in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidWorld

      public void onInvalidWorld(revxrsal.commands.bukkit.exception.MissingLocationParameterException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when a required location axis parameter is missing.

      Locale key: commands.missing-location-parameter

      Overrides:
      onInvalidWorld in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onSenderNotConsole

      public void onSenderNotConsole(revxrsal.commands.bukkit.exception.SenderNotConsoleException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when a non-console sender runs a console-only command.

      Locale key: commands.sender-not-console

      Overrides:
      onSenderNotConsole in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onSenderNotPlayer

      public void onSenderNotPlayer(revxrsal.commands.bukkit.exception.SenderNotPlayerException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when a non-player sender runs a player-only command.

      Locale key: commands.sender-not-player

      Overrides:
      onSenderNotPlayer in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onMalformedEntitySelector

      public void onMalformedEntitySelector(revxrsal.commands.bukkit.exception.MalformedEntitySelectorException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message for a malformed entity selector.

      Locale key: commands.malformed-entity-selector

      Overrides:
      onMalformedEntitySelector in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onNonPlayerEntities

      public void onNonPlayerEntities(revxrsal.commands.bukkit.exception.NonPlayerEntitiesException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when an entity selector targets non-player entities but only players are allowed.

      Locale key: commands.non-player-entities

      Overrides:
      onNonPlayerEntities in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onMoreThanOneEntity

      public void onMoreThanOneEntity(revxrsal.commands.bukkit.exception.MoreThanOneEntityException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when an entity selector matches more than one entity but only one is allowed.

      Locale key: commands.more-than-one-entity

      Overrides:
      onMoreThanOneEntity in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onEmptyEntitySelector

      public void onEmptyEntitySelector(revxrsal.commands.bukkit.exception.EmptyEntitySelectorException e, revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when an entity selector matches no entities.

      Locale key: commands.empty-entity-selector

      Overrides:
      onEmptyEntitySelector in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onEnumNotFound

      public void onEnumNotFound(@NotNull @NotNull revxrsal.commands.exception.EnumNotFoundException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when input does not match any enum constant.

      Locale key: commands.enum-not-found

      Overrides:
      onEnumNotFound in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onExpectedLiteral

      public void onExpectedLiteral(@NotNull @NotNull revxrsal.commands.exception.ExpectedLiteralException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when a literal node received unexpected input.

      Locale key: commands.expected-literal

      Overrides:
      onExpectedLiteral in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInputParse

      public void onInputParse(@NotNull @NotNull revxrsal.commands.exception.InputParseException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message for input parsing failures. The specific message depends on the parse error cause:
      • Invalid escape character: commands.input-parse.invalid-escape
      • Unclosed quote: commands.input-parse.unclosed-quote
      • Expected whitespace: commands.input-parse.expected-whitespace
      Overrides:
      onInputParse in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidListSize

      public void onInvalidListSize(@NotNull @NotNull revxrsal.commands.exception.InvalidListSizeException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor, @NotNull @NotNull revxrsal.commands.node.ParameterNode<revxrsal.commands.bukkit.actor.BukkitCommandActor,?> parameter)
      Sends a localized error message when a list argument has too few or too many entries.
      • Too few entries: commands.invalid-list-size.too-small
      • Too many entries: commands.invalid-list-size.too-large
      Overrides:
      onInvalidListSize in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidStringSize

      public void onInvalidStringSize(@NotNull @NotNull revxrsal.commands.exception.InvalidStringSizeException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor, @NotNull @NotNull revxrsal.commands.node.ParameterNode<revxrsal.commands.bukkit.actor.BukkitCommandActor,?> parameter)
      Sends a localized error message when a string argument is too short or too long.
      • Too short: commands.invalid-string-size.too-small
      • Too long: commands.invalid-string-size.too-large
      Overrides:
      onInvalidStringSize in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidBoolean

      public void onInvalidBoolean(@NotNull @NotNull revxrsal.commands.exception.InvalidBooleanException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when input cannot be parsed as a boolean.

      Locale key: commands.invalid-boolean

      Overrides:
      onInvalidBoolean in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidDecimal

      public void onInvalidDecimal(@NotNull @NotNull revxrsal.commands.exception.InvalidDecimalException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when input cannot be parsed as a decimal number.

      Locale key: commands.invalid-decimal

      Overrides:
      onInvalidDecimal in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidInteger

      public void onInvalidInteger(@NotNull @NotNull revxrsal.commands.exception.InvalidIntegerException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when input cannot be parsed as an integer.

      Locale key: commands.invalid-integer

      Overrides:
      onInvalidInteger in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidUUID

      public void onInvalidUUID(@NotNull @NotNull revxrsal.commands.exception.InvalidUUIDException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when input cannot be parsed as a UUID.

      Locale key: commands.invalid-uuid

      Overrides:
      onInvalidUUID in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onMissingArgument

      public void onMissingArgument(@NotNull @NotNull revxrsal.commands.exception.MissingArgumentException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor, @NotNull @NotNull revxrsal.commands.node.ParameterNode<revxrsal.commands.bukkit.actor.BukkitCommandActor,?> parameter)
      Sends a localized error message when a required command argument is missing.

      Locale key: commands.missing-argument

      Overrides:
      onMissingArgument in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onNoPermission

      public void onNoPermission(@NotNull @NotNull revxrsal.commands.exception.NoPermissionException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when the sender lacks permission to run the command.

      Locale key: commands.no-permission

      Overrides:
      onNoPermission in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onNumberNotInRange

      public void onNumberNotInRange(@NotNull @NotNull revxrsal.commands.exception.NumberNotInRangeException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor, @NotNull @NotNull revxrsal.commands.node.ParameterNode<revxrsal.commands.bukkit.actor.BukkitCommandActor,Number> parameter)
      Sends a localized error message when a numeric argument falls outside its allowed range.
      • Below minimum: commands.number-not-in-range.too-small
      • Above maximum: commands.number-not-in-range.too-large
      Overrides:
      onNumberNotInRange in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onInvalidHelpPage

      public void onInvalidHelpPage(@NotNull @NotNull revxrsal.commands.exception.InvalidHelpPageException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message for an out-of-range help page number. Uses commands.invalid-help-page.single when there is only one page, otherwise commands.invalid-help-page.multiple.
      Overrides:
      onInvalidHelpPage in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onUnknownCommand

      public void onUnknownCommand(@NotNull @NotNull revxrsal.commands.exception.UnknownCommandException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when the input does not match any known command.

      Locale key: commands.unknown-command

      Overrides:
      onUnknownCommand in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onValueNotAllowed

      public void onValueNotAllowed(@NotNull @NotNull revxrsal.commands.exception.ValueNotAllowedException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when the provided value is not in the set of allowed values.

      Locale key: commands.value-not-allowed

      Overrides:
      onValueNotAllowed in class revxrsal.commands.bukkit.exception.BukkitExceptionHandler
    • onCommandInvocation

      public void onCommandInvocation(@NotNull @NotNull revxrsal.commands.exception.CommandInvocationException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized internal error message and logs the underlying cause when command execution throws an unexpected exception.

      Locale key: commands.internal-error

      Overrides:
      onCommandInvocation in class revxrsal.commands.exception.DefaultExceptionHandler<revxrsal.commands.bukkit.actor.BukkitCommandActor>
    • onUnknownParameter

      public void onUnknownParameter(@NotNull @NotNull revxrsal.commands.exception.UnknownParameterException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message for an unrecognized flag or shorthand parameter. Uses commands.unknown-parameter.shorthand for shorthand flags, otherwise commands.unknown-parameter.flag.
      Overrides:
      onUnknownParameter in class revxrsal.commands.exception.DefaultExceptionHandler<revxrsal.commands.bukkit.actor.BukkitCommandActor>
    • onCooldown

      public void onCooldown(@NotNull @NotNull revxrsal.commands.exception.CooldownException e, @NotNull @NotNull revxrsal.commands.bukkit.actor.BukkitCommandActor actor)
      Sends a localized error message when a command is on cooldown, including the remaining wait time formatted with the concise duration formatter.

      Locale key: commands.cooldown

      Overrides:
      onCooldown in class revxrsal.commands.exception.DefaultExceptionHandler<revxrsal.commands.bukkit.actor.BukkitCommandActor>