3. First command
To create your first command, you need to create a class with the @Command annotation and a method with the @Execute annotation.
java
@Command(name = "hello")
public class HelloCommand {
@Execute
void hello(@Context CommandSender sender, @Arg String username) {
sender.sendMessage("Hello, " + username + "!");
}
}TIP
If you don't know how to create a LiteCommands builder, check the 2. Configure Builder page.
Now, register the command in a LiteCommands builder:
java
.commands(
new HelloCommand()
)Now, you can use the /hello command in your server:
/hello <username>
Input
/hello RollcziOutput
Hello, Rollczi!
Norbert Dejlich