mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-11-22 01:48:50 +00:00
feat: 调整注解参数 添加doc
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
8f9597bcce
commit
02bbe0892b
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -8,6 +8,16 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* 命令注解
|
||||
*
|
||||
* <pre>
|
||||
* 参数名称 描述 默认值
|
||||
* name 命令名称 方法名称
|
||||
* aliases 命令别名
|
||||
* minimumArguments 最小参数 默认0
|
||||
* permission 权限
|
||||
* onlyPlayer 只允许玩家 false
|
||||
* onlyConsole 只允许控制台 false
|
||||
* </pre>
|
||||
*
|
||||
* @since 2016年7月23日 上午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 当前命令权限
|
||||
|
@ -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 当前命令可能需要的参数
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pw.yumc.YumCore.commands.annotation;
|
||||
|
||||
/**
|
||||
* 命令排序注解
|
||||
*
|
||||
* @since 2016年7月23日 上午9:04:56
|
||||
* @author 喵♂呜
|
||||
@ -9,5 +10,5 @@ public @interface Sort {
|
||||
/**
|
||||
* @return 命令排序
|
||||
*/
|
||||
int sort();
|
||||
int value();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user