/*
* This file is part of OneConfig.
* OneConfig - Next Generation Config Library for Minecraft: Java Edition
* Copyright (C) 2021, 2022 Polyfrost.
*
* To start, create a class which is annotated with this annotation, and then a method which is annotated with {@link Main}.
*
* Keep in mind how {@code mainCommandMethod} is a private and static method.
* With OneConfig's command utility, methods for commands can be any kind of visibility, and must be static.
* If the methods are not static, the {@link CommandManager} will throw an exception.
*
*
* Command methods can also having multiple parameters of virtually any type, as long as it is a
* {@link String}, {@code boolean}, {@code int}, {@code double}, {@code float},
* or is added as an {@link ArgumentParser} and added to the
* {@link CommandManager} via {@link CommandManager#addParser(ArgumentParser)}.
* Parameters can also be annotated with various annotations, such as {@link Name}, which names the parameter
* for the user, {@link Greedy}, which takes all following arguments along with itself, and more to come.
* For example, the following command method:
* {@code
* @literal @Command(name = "test", description = "A test command", aliases = {"t"})
* public class TestCommand {
* @literal @Main
* public static void mainCommandMethod() {
* // do stuff
* }
* }
* }
* {@code
* @literal @Main
* private static void mainCommandMethod(String arg1, @Name("nameOfSecondArgument") boolean arg2, int arg3, double arg4, float arg5, @Greedy String greedyArgument) {
* // do things here
* System.out.println(greedyArgument); // Greedily takes all remaining arguments after greedyArgument as well as itself. 1984
* }
* }
*
* Of course, {@link SubCommand}s can be added and "stacked". For example, the following command class: *
{@code * @literal @Command(name = "mycommand", aliases = {"alias1"}, description = "My command description") * public class TestCommand { * @literal @Main * private static void mainCommandMethod() { * // do things here * } * * @literal @SubCommand(name = "subcommand", aliases = {"subalias1"}, description = "My subcommand description") * private static class SubCommandClass { * @literal @Main * private static void subCommandMethod() { * // do things here * } * * @literal @SubCommand(name = "subsubcommand", aliases = {"subsubalias1"}, description = "My subsubcommand description") * private static class SubSubCommandClass { * @literal @Main * private static void subSubCommandMethod() { * // do things here * } * } * } * } * }* *
* To register commands, use {@link CommandManager#registerCommand(Class)}. * *
* Note: if you're viewing this in IntelliJ or just see the @literal tag everywhere, please ignore that. *
* * @see OneConfigCommand * @see Main * @see CommandManager */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface Command { /** * The name of the command. * * @return The name of the command. */ String value(); /** * The aliases of the command. * * @return The aliases of the command. */ String[] aliases() default {}; /** * The description of the command. * * @return The description of the command. */ String description() default ""; /** * The color of the command. * * @return The color of the command. */ ChatColor color() default ChatColor.GOLD; /** * Whether the command generates a help command. */ boolean helpCommand() default true; }