Skip to content

Hey there! If you like my work, you can support me by sponsoring me on GitHub. Thanks! ❤

Sponsor me
on GitHub

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 Rollczi
Output
Hello, Rollczi!

Made by LiteDevelopers and Contributors with ❤️