From 6764704c2273f07698965e87366e962d62f96778 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 5 Dec 2011 10:38:44 +0100 Subject: [PATCH] Added support for help text to be shown on syntax errors and such. --- .../java/com/sk89q/minecraft/util/commands/Command.java | 5 +++++ .../sk89q/minecraft/util/commands/CommandsManager.java | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/minecraft/util/commands/Command.java b/src/main/java/com/sk89q/minecraft/util/commands/Command.java index 0efb36b31..fd7ca5e0f 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/Command.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/Command.java @@ -67,4 +67,9 @@ public @interface Command { * meaning that if it is given it must have a value */ String flags() default ""; + + /** + * A long description for the command. + */ + String help() default ""; } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java index 69b18d0e5..a72a6586e 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java @@ -242,7 +242,7 @@ public abstract class CommandsManager { * @return */ protected String getUsage(String[] args, int level, Command cmd) { - StringBuilder command = new StringBuilder(); + final StringBuilder command = new StringBuilder(); command.append('/'); @@ -262,6 +262,12 @@ public abstract class CommandsManager { } command.append(cmd.usage()); + final String help = cmd.help(); + if (!help.isEmpty()) { + command.append("\n\n"); + command.append(help); + } + return command.toString(); }