@Join
To concatenate multiple arguments into a single string, use the @Join
annotation.
java
@Command(name = "ban")
public class BanCommand {
@Execute
void ban(@Arg Player target, @Join String reason) {
// Command implementation
}
}
Let's consider the following command usage:
/ban <player> <reason...>
Input
/ban JohnDoe Offensive language and behaviortarget
JohnDoereason
Offensive language and behaviorAdditional Options
Sometimes you may want to limit the number of arguments that will be joined.
java
@Join(limit = 2)
Or you may want to join arguments with a different separator.
java
@Join(separator = ", ")
Or both:
java
@Command(name = "ban")
public class BanCommand {
@Execute
public void ban(
@Arg Player target,
@Join(limit = 10, separator = "-") String reason
) {
// Command implementation
}
}
Now, our result will be:
/ban <player> <reason...>
Input
/ban JohnDoe Offensive language and behaviortarget
JohnDoereason
Offensive-language-and-behavior