Skip to content

Creating a command

Olafcio1 edited this page Aug 20, 2026 · 2 revisions

This guide assumes you've already created and setup an Avoid project.
This guide uses meta-programming. Another way may either not be implemented or you may need to figure it out on your own.


§ Making a command with the Avoid Framework


  1. Create a java class;
    You can pick any location within your project source code directory.

  2. Paste the following code:

    package com.example.avoidtmpl;
    
    import pl.olafcio.avoid.mods.annotation_processor.AutoCommand;
    import pl.olafcio.avoid.net.chat.Chat;
    import pl.olafcio.avoid.net.chat.component.Components;
    import pl.olafcio.avoid.net.command.Command;
    import pl.olafcio.avoid.net.command.annotation.Syntax;
    import pl.olafcio.avoid.net.command.annotation.Unknown;
    import pl.olafcio.avoid.net.command.handling.Usage;
    import pl.olafcio.avoid.net.player.Player;
    
    @AutoCommand
    public class LoveCmd extends Command {
        @Syntax("/love")
        public static void just(Usage input) {
            input.getExecutor().sendMessage(Components.literal("§7[LovePlugin]§c Usage: §n/love <player>"));
        }
    
        @Syntax("/love <player>")
        public static void forPlayer(Usage input) {
            var plr = input.getArgument("player", Player.class);
    
            input.getExecutor().sendMessage(Components.literal("§7[LovePlugin]§c You love " + plr + "!"));
            plr.sendMessage(Components.literal("§7[LovePlugin]§c " + input.getExecutor().getName() + " loves you!"));
        }
    }

    Of course you need to replace the class name and package.

  3. Customize it as you wish;
    To define a syntax, you can make another method marked with @Syntax.
    To handle any syntax, use @Unknown. @Syntax methods have priority over it.


Avoid Framework


    🏚️ 1. Home
    📽️ 2. Creating your mod
    🌄 3. Adding assets to your mod
    🧊 4. Creating a block
    💧 5. Creating a fluid
    ✏️ 6. Creating an item
    🎯 7. Creating an entity selector
    🤖 8. Creating a command
    ⌨️ 9. Creating a keybind
    🐺 10. Creating an entity
    🌫️ 11. Creating a fog
    🔩 12. Creating an item component
    🔮 13. Creating an effect

Clone this wiki locally