Add ability to show a per-command usage + apply "correct indentation".

This commit is contained in:
asofold 2014-07-29 11:55:53 +02:00
parent 1aa62de1dd
commit 9b6c717fc0

View File

@ -95,6 +95,9 @@ public abstract class AbstractCommand<A> implements TabExecutor{
/** Aliases for the command label. */
protected final String[] aliases;
/** This is only shown if a parent command receives false for onCommand and if it is not null. */
protected String usage = null;
/**
*
* @param access
@ -176,7 +179,13 @@ public abstract class AbstractCommand<A> implements TabExecutor{
sender.sendMessage(ChatColor.DARK_RED + "You don't have permission.");
return true;
}
return subCommand.onCommand(sender, command, alias, args);
final boolean res = subCommand.onCommand(sender, command, alias, args);
if (!res && subCommand.usage != null) {
sender.sendMessage(subCommand.usage);
return true;
} else {
return res;
}
}
}
// Usage.