Commit ef3579da authored by 方块君's avatar 方块君 Committed by Melledy
Browse files

add Command description

parent a46d58e5
......@@ -9,6 +9,8 @@ public @interface Command {
String usage() default "No usage specified";
String description() default "No description specified";
String[] aliases() default {};
String permission() default "";
......
......@@ -7,7 +7,7 @@ import java.util.List;
public interface CommandHandler {
String description();
default String description() { return null; };
/**
* Send a message to the target.
......
......@@ -43,7 +43,7 @@ public final class HelpCommand implements CommandHandler {
} else {
Command annotation = handler.getClass().getAnnotation(Command.class);
builder.append(" ").append(handler.description()).append("\n");
builder.append(" ").append(handler.description() == null ? annotation.description(): handler.description()).append("\n");
builder.append(translate("commands.help.usage")).append(annotation.usage());
if (annotation.aliases().length >= 1) {
builder.append("\n").append(translate("commands.help.aliases"));
......@@ -65,7 +65,7 @@ public final class HelpCommand implements CommandHandler {
StringBuilder builder = new StringBuilder("\n" + translate("commands.help.available_commands") + "\n");
annotations.forEach((annotation, handler) -> {
builder.append(annotation.label()).append("\n");
builder.append(" ").append(handler.description()).append("\n");
builder.append(" ").append(handler.description() == null ? annotation.description() : handler.description()).append("\n");
builder.append(translate("commands.help.usage")).append(annotation.usage());
if (annotation.aliases().length >= 1) {
builder.append("\n").append(translate("commands.help.aliases"));
......@@ -82,7 +82,7 @@ public final class HelpCommand implements CommandHandler {
CommandHandler.sendMessage(player, translate("commands.help.available_commands"));
annotations.forEach((annotation, handler) -> {
StringBuilder builder = new StringBuilder(annotation.label()).append("\n");
builder.append(" ").append(handler.description()).append("\n");
builder.append(" ").append(handler.description() == null ? annotation.description() : handler.description()).append("\n");
builder.append(translate("commands.help.usage")).append(annotation.usage());
if (annotation.aliases().length >= 1) {
builder.append("\n").append(translate("commands.help.aliases"));
......
......@@ -121,7 +121,7 @@ final class ToolsWithLanguageOption {
while (cmdName.length() <= 15) {
cmdName = " " + cmdName;
}
writer.println(cmdName + " : " + handler.description());
writer.println(cmdName + " : " + (handler.description() == null ? command.description() : handler.description()));
});
writer.println();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment