feat: 调整注解参数 添加doc

Signed-off-by: 502647092 <admin@yumc.pw>
merge/1/MERGE
502647092 2016-07-25 15:45:02 +08:00
parent 8f9597bcce
commit 02bbe0892b
5 changed files with 186 additions and 175 deletions

View File

@ -95,7 +95,7 @@ public class CommandHelp {
final String cmd = ci.getName() + (aliases.length() == 2 ? "" : "§7" + aliases);
final Help help = ci.getHelp();
// 帮助列表
helpList.add(String.format(helpBody, label, cmd, help.possibleArguments(), help.description()));
helpList.add(String.format(helpBody, label, cmd, help.possibleArguments(), help.value()));
}
}
}

View File

@ -43,7 +43,7 @@ public class CommandInfo {
public CommandInfo(final Method method, final Object origin, final Cmd command, final Help help, final boolean async, final int sort) {
this.method = method;
this.origin = origin;
this.name = "".equals(command.name()) ? method.getName().toLowerCase() : command.name();
this.name = "".equals(command.value()) ? method.getName().toLowerCase() : command.value();
this.aliases = Arrays.asList(command.aliases());
this.command = command;
this.help = help;
@ -77,7 +77,7 @@ public class CommandInfo {
final Help help = method.getAnnotation(Help.class);
final Async async = method.getAnnotation(Async.class);
final Sort sort = method.getAnnotation(Sort.class);
return new CommandInfo(method, origin, command, help != null ? help : Help.DEFAULT, async != null, sort != null ? sort.sort() : 50);
return new CommandInfo(method, origin, command, help != null ? help : Help.DEFAULT, async != null, sort != null ? sort.value() : 50);
}
return null;
}
@ -184,11 +184,11 @@ public class CommandInfo {
if (cmdArgs.getArgs().length < command.minimumArguments()) {
Log.toSender(sender, cmdErr);
Log.toSender(sender, String.format(cmdUse, cmdArgs.getAlias(), getName(), help.possibleArguments()));
Log.toSender(sender, String.format(cmdDes, help.description()));
Log.toSender(sender, String.format(cmdDes, help.value()));
}
if (sender instanceof Player && command.onlyConsoleExecutable()) {
if (sender instanceof Player && command.onlyConsole()) {
Log.toSender(sender, onlyConsole);
} else if (command.onlyPlayerExecutable()) {
} else if (command.onlyPlayer()) {
Log.toSender(sender, onlyPlayer);
}
final String perm = command.permission();

View File

@ -8,6 +8,16 @@ import java.lang.annotation.Target;
/**
*
*
* <pre>
*
* name
* aliases
* minimumArguments 0
* permission
* onlyPlayer false
* onlyConsole false
* </pre>
*
* @since 2016723 8:59:05
* @author
*/
@ -27,17 +37,17 @@ public @interface Cmd {
/**
* @return
*/
String name() default "";
String value() default "";
/**
* @return
*/
boolean onlyConsoleExecutable() default false;
boolean onlyConsole() default false;
/**
* @return
*/
boolean onlyPlayerExecutable() default false;
boolean onlyPlayer() default false;
/**
* @return

View File

@ -22,7 +22,7 @@ public @interface Help {
}
@Override
public String description() {
public String value() {
return "没写帮助信息";
}
@ -35,7 +35,7 @@ public @interface Help {
/**
* @return
*/
String description();
String value();
/**
* @return

View File

@ -1,6 +1,7 @@
package pw.yumc.YumCore.commands.annotation;
/**
*
*
* @since 2016723 9:04:56
* @author
@ -9,5 +10,5 @@ public @interface Sort {
/**
* @return
*/
int sort();
int value();
}