Adventure Usage Argument For example, you can use the Component
object as an argument in your command:
@Execute(name = "tell")
void tell(@Context SENDER sender, @Arg SENDER target, @Join Component message) {
target.sendMessage(message);
}
Response You can also use the Component
object as a response:
@Execute(name = "info")
Component info() {
return Component.text("This is an example of the Component response.");
}
Colorizer Colorizer is a feature that allows you to colorize the Component
object in the @Arg
argument.
If you want to use the default colorizer, you need to enable it in the LiteCommands
builder:
.extension(new LiteAdventureExtension<SENDER>()
.colorizeArgument(true)
)
.extension(new LiteAdventurePlatformExtension<SENDER>(this.audienceProvider)
.colorizeArgument(true)
)
You can force enable the colorizer for the specific argument:
@Execute(name = "colorize")
void colorize(@Arg @Key("color") Component colorized) {
// ...
}
And you can also force disable the colorizer:
@Execute(name = "raw")
void raw(@Arg @Key("raw") Component notColorized) {
// ...
}
Serializer (Colorizer) Serializer is used to colorize the Component
object in the @Arg
argument and the response.
You can modify the default serializer by using the miniMessage()
and legacyColor()
methods in the LiteCommands
builder:
.extension(new LiteAdventureExtension<SENDER>()
.miniMessage(true)
.legacyColor(true)
)
.extension(new LiteAdventurePlatformExtension<SENDER>(this.audienceProvider)
.miniMessage(true)
.legacyColor(true)
)
The miniMessage()
method enables the MiniMessage support. Read more about it here . The legacyColor()
method enables the legacy color support. &c
, &a
, etc.
If you want to use the custom serializer, you need to set it in the LiteCommands
builder:
.extension(new LiteAdventureExtension<SENDER>()
.serializer(this.miniMessage)
)
.extension(new LiteAdventurePlatformExtension<SENDER>(this.audienceProvider)
.serializer(this.miniMessage)
)
Remember to replace SENDER
with your sender type that corresponds to the platform you are using. See What is SENDER? for more information.
Last modified: 31 October 2023