mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 01:21:30 +00:00
add Command description
This commit is contained in:
parent
05e1e5502c
commit
f49862145c
@ -9,6 +9,8 @@ public @interface Command {
|
|||||||
|
|
||||||
String usage() default "No usage specified";
|
String usage() default "No usage specified";
|
||||||
|
|
||||||
|
String description() default "No description specified";
|
||||||
|
|
||||||
String[] aliases() default {};
|
String[] aliases() default {};
|
||||||
|
|
||||||
String permission() default "";
|
String permission() default "";
|
||||||
|
@ -7,7 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface CommandHandler {
|
public interface CommandHandler {
|
||||||
|
|
||||||
String description();
|
default String description() { return null; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to the target.
|
* Send a message to the target.
|
||||||
|
@ -43,7 +43,7 @@ public final class HelpCommand implements CommandHandler {
|
|||||||
} else {
|
} else {
|
||||||
Command annotation = handler.getClass().getAnnotation(Command.class);
|
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());
|
builder.append(translate("commands.help.usage")).append(annotation.usage());
|
||||||
if (annotation.aliases().length >= 1) {
|
if (annotation.aliases().length >= 1) {
|
||||||
builder.append("\n").append(translate("commands.help.aliases"));
|
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");
|
StringBuilder builder = new StringBuilder("\n" + translate("commands.help.available_commands") + "\n");
|
||||||
annotations.forEach((annotation, handler) -> {
|
annotations.forEach((annotation, handler) -> {
|
||||||
builder.append(annotation.label()).append("\n");
|
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());
|
builder.append(translate("commands.help.usage")).append(annotation.usage());
|
||||||
if (annotation.aliases().length >= 1) {
|
if (annotation.aliases().length >= 1) {
|
||||||
builder.append("\n").append(translate("commands.help.aliases"));
|
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"));
|
CommandHandler.sendMessage(player, translate("commands.help.available_commands"));
|
||||||
annotations.forEach((annotation, handler) -> {
|
annotations.forEach((annotation, handler) -> {
|
||||||
StringBuilder builder = new StringBuilder(annotation.label()).append("\n");
|
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());
|
builder.append(translate("commands.help.usage")).append(annotation.usage());
|
||||||
if (annotation.aliases().length >= 1) {
|
if (annotation.aliases().length >= 1) {
|
||||||
builder.append("\n").append(translate("commands.help.aliases"));
|
builder.append("\n").append(translate("commands.help.aliases"));
|
||||||
|
@ -121,7 +121,7 @@ final class ToolsWithLanguageOption {
|
|||||||
while (cmdName.length() <= 15) {
|
while (cmdName.length() <= 15) {
|
||||||
cmdName = " " + cmdName;
|
cmdName = " " + cmdName;
|
||||||
}
|
}
|
||||||
writer.println(cmdName + " : " + handler.description());
|
writer.println(cmdName + " : " + (handler.description() == null ? command.description() : handler.description()));
|
||||||
});
|
});
|
||||||
writer.println();
|
writer.println();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user