-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a command
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
-
Create a java class;
You can pick any location within your project source code directory. -
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.
-
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.
©️ Copyright 2026 Olafcio (on behalf of the AvoidLib org)
📝 Licensed with CC BY-NC (Attribution-NonCommercial)
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