Class MinecraftExceptionHandler<C>
java.lang.Object
cloud.commandframework.minecraft.extras.MinecraftExceptionHandler<C>
- Type Parameters:
C- Command sender type
Exception handler that sends
Component to the sender. All component builders
can be overridden and the handled exception types can be configured (see MinecraftExceptionHandler.ExceptionType for types)-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumException types -
Field Summary
FieldsModifier and TypeFieldDescriptionDefault component builder forArgumentParseExceptionDefault component builder forCommandExecutionExceptionDefault component builder forInvalidCommandSenderExceptionDefault component builder forInvalidSyntaxExceptionDefault component builder forNoPermissionException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(@NonNull cloud.commandframework.CommandManager<C> manager, @NonNull Function<@NonNull C, @NonNull net.kyori.adventure.audience.Audience> audienceMapper) Register the exception handlers in the manager@NonNull MinecraftExceptionHandler<C>Use the default argument parsing handler@NonNull MinecraftExceptionHandler<C>Use the defaultCommandExecutionExceptionhandler@NonNull MinecraftExceptionHandler<C>withDecorator(@NonNull Function<@NonNull net.kyori.adventure.text.Component, @NonNull net.kyori.adventure.text.Component> decorator) Specify a decorator that acts on a component before it's sent to the sender@NonNull MinecraftExceptionHandler<C>Use all of the default exception handlers@NonNull MinecraftExceptionHandler<C>withHandler(@NonNull MinecraftExceptionHandler.ExceptionType type, @NonNull BiFunction<@NonNull C, @NonNull Exception, @NonNull net.kyori.adventure.text.Component> componentBuilder) Specify an exception handler@NonNull MinecraftExceptionHandler<C>withHandler(@NonNull MinecraftExceptionHandler.ExceptionType type, @NonNull Function<@NonNull Exception, @NonNull net.kyori.adventure.text.Component> componentBuilder) Specify an exception handler@NonNull MinecraftExceptionHandler<C>Use the default invalid sender handler@NonNull MinecraftExceptionHandler<C>Use the default invalid syntax handler@NonNull MinecraftExceptionHandler<C>Use the default no permission handler
-
Field Details
-
DEFAULT_INVALID_SYNTAX_FUNCTION
public static final Function<Exception,net.kyori.adventure.text.Component> DEFAULT_INVALID_SYNTAX_FUNCTIONDefault component builder forInvalidSyntaxException -
DEFAULT_INVALID_SENDER_FUNCTION
public static final Function<Exception,net.kyori.adventure.text.Component> DEFAULT_INVALID_SENDER_FUNCTIONDefault component builder forInvalidCommandSenderException -
DEFAULT_NO_PERMISSION_FUNCTION
public static final Function<Exception,net.kyori.adventure.text.Component> DEFAULT_NO_PERMISSION_FUNCTIONDefault component builder forNoPermissionException -
DEFAULT_ARGUMENT_PARSING_FUNCTION
public static final Function<Exception,net.kyori.adventure.text.Component> DEFAULT_ARGUMENT_PARSING_FUNCTIONDefault component builder forArgumentParseException -
DEFAULT_COMMAND_EXECUTION_FUNCTION
public static final Function<Exception,net.kyori.adventure.text.Component> DEFAULT_COMMAND_EXECUTION_FUNCTIONDefault component builder forCommandExecutionException- Since:
- 1.2.0
-
-
Constructor Details
-
MinecraftExceptionHandler
public MinecraftExceptionHandler()
-
-
Method Details
-
withInvalidSyntaxHandler
Use the default invalid syntax handler- Returns:
this
-
withInvalidSenderHandler
Use the default invalid sender handler- Returns:
this
-
withNoPermissionHandler
Use the default no permission handler- Returns:
this
-
withArgumentParsingHandler
Use the default argument parsing handler- Returns:
this
-
withCommandExecutionHandler
Use the defaultCommandExecutionExceptionhandler- Returns:
this- Since:
- 1.2.0
-
withDefaultHandlers
Use all of the default exception handlers- Returns:
this
-
withHandler
public @NonNull MinecraftExceptionHandler<C> withHandler(@NonNull MinecraftExceptionHandler.ExceptionType type, @NonNull Function<@NonNull Exception, @NonNull net.kyori.adventure.text.Component> componentBuilder) Specify an exception handler- Parameters:
type- Exception typecomponentBuilder- Component builder- Returns:
this
-
withHandler
public @NonNull MinecraftExceptionHandler<C> withHandler(@NonNull MinecraftExceptionHandler.ExceptionType type, @NonNull BiFunction<@NonNull C, @NonNull Exception, @NonNull net.kyori.adventure.text.Component> componentBuilder) Specify an exception handler- Parameters:
type- Exception typecomponentBuilder- Component builder- Returns:
this- Since:
- 1.2.0
-
withDecorator
public @NonNull MinecraftExceptionHandler<C> withDecorator(@NonNull Function<@NonNull net.kyori.adventure.text.Component, @NonNull net.kyori.adventure.text.Component> decorator) Specify a decorator that acts on a component before it's sent to the sender- Parameters:
decorator- Component decorator- Returns:
this
-
apply
public void apply(@NonNull cloud.commandframework.CommandManager<C> manager, @NonNull Function<@NonNull C, @NonNull net.kyori.adventure.audience.Audience> audienceMapper) Register the exception handlers in the manager- Parameters:
manager- Manager instanceaudienceMapper- Mapper that maps command sender to audience instances
-