package net.kelsoncraft.test; import com.mojang.brigadier.CommandDispatcher; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; // https://www.reddit.com/r/fabricmc/comments/r3bd47/fabric_execute_commands/ public class CommandTest { // This idea came from here: // https://github.com/Draylar/get-off-my-lawn/blob/1.17/src/main/java/draylar/goml/command/ClaimCommand.java#L32-L98 public CommandTest() { } // This works like this, now I know how to add commands to other classes, add them like this then initialize them in the main class. public static void init() { CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(CommandManager.literal("teleport") .executes(context -> { context.getSource().sendFeedback(() -> Text.literal("Teleport to %s"), false); return 1; }))); } }