Refactored command handling code to be more reusable.

This commit is contained in:
sk89q
2011-02-24 16:39:23 -08:00
parent 50b9f300d5
commit ad62dbe565
12 changed files with 354 additions and 82 deletions

View File

@@ -21,12 +21,48 @@ package com.sk89q.minecraft.util.commands;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* This annotation indicates a command. Methods should be marked with this
* annotation to tell {@link CommandsManager} that the method is a command.
* Note that the method name can actually be anything.
*
* @author sk89q
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Command {
/**
* A list of aliases for the command. The first alias is the most
* important -- it is the main name of the command. (The method name
* is never used for anything).
*/
String[] aliases();
/**
* Usage instruction. Example text for usage could be
* <code>[-h] [name] [message]</code>.
*/
String usage() default "";
/**
* A short description for the command.
*/
String desc();
/**
* The minimum number of arguments. This should be 0 or above.
*/
int min() default 0;
/**
* The maximum number of arguments. Use -1 for an unlimited number
* of arguments.
*/
int max() default -1;
/**
* Flags allow special processing for flags such as -h in the command,
* allowing users to easily turn on a flag. This is a string with
* each character being a flag. Use A-Z and a-z as possible flags.
*/
String flags() default "";
}