✨ Add adventure-based exception handlers to cloud-minecraft-extras
This commit is contained in:
parent
423b29ee3c
commit
4368305bc9
2 changed files with 255 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ package cloud.commandframework.examples.bukkit;
|
|||
import cloud.commandframework.Command;
|
||||
import cloud.commandframework.CommandTree;
|
||||
import cloud.commandframework.Description;
|
||||
import cloud.commandframework.MinecraftExceptionHandler;
|
||||
import cloud.commandframework.MinecraftHelp;
|
||||
import cloud.commandframework.annotations.AnnotationParser;
|
||||
import cloud.commandframework.annotations.Argument;
|
||||
|
|
@ -179,6 +180,23 @@ public final class ExamplePlugin extends JavaPlugin {
|
|||
/* Mapper for command meta instances */ commandMetaFunction
|
||||
);
|
||||
//
|
||||
// Override the default exception handlers
|
||||
//
|
||||
new MinecraftExceptionHandler<CommandSender>()
|
||||
.withInvalidSyntaxHandler()
|
||||
.withInvalidSenderHandler()
|
||||
.withNoPermissionHandler()
|
||||
.withArgumentParsingHandler()
|
||||
.withDecorator(
|
||||
component -> Component.text().append(
|
||||
Component.text("[", NamedTextColor.DARK_GRAY)
|
||||
).append(
|
||||
Component.text("Example", NamedTextColor.GOLD)
|
||||
).append(
|
||||
Component.text("] ", NamedTextColor.DARK_GRAY)
|
||||
).append(component).build()
|
||||
).apply(manager, bukkitAudiences::sender);
|
||||
//
|
||||
// Create the commands
|
||||
//
|
||||
this.constructCommands();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue