Skip to content

Creating a command

Olafcio1 edited this page Jun 16, 2026 · 1 revision

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("/echo <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 an item
    🎯 6. Creating an entity selector
    🤖 7. Creating a command

Clone this wiki locally