Added 'commands.help.syntax-no-parameters' to avoid command help layout inconsistencies

Fixes #379
This commit is contained in:
Florian CUNY 2018-12-14 15:44:33 +01:00
parent fa5c7905da
commit 8a16940e14
2 changed files with 12 additions and 2 deletions

View File

@ -22,6 +22,7 @@ public class DefaultHelpCommand extends CompositeCommand {
private static final String PARAMS_PLACEHOLDER = "[parameters]";
private static final String DESC_PLACEHOLDER = "[description]";
private static final String HELP_SYNTAX_REF = "commands.help.syntax";
private static final String HELP_SYNTAX_NO_PARAMETERS_REF = "commands.help.syntax-no-parameters";
private static final String HELP = "help";
public DefaultHelpCommand(CompositeCommand parent) {
@ -93,14 +94,22 @@ public class DefaultHelpCommand extends CompositeCommand {
if (user.isPlayer()) {
// Player. Check perms
if (user.isOp() || user.hasPermission(parent.getPermission())) {
user.sendMessage(HELP_SYNTAX_REF, USAGE_PLACEHOLDER, usage, PARAMS_PLACEHOLDER, params, DESC_PLACEHOLDER, desc);
if (params.isEmpty()) {
user.sendMessage(HELP_SYNTAX_NO_PARAMETERS_REF, USAGE_PLACEHOLDER, usage, DESC_PLACEHOLDER, desc);
} else {
user.sendMessage(HELP_SYNTAX_REF, USAGE_PLACEHOLDER, usage, PARAMS_PLACEHOLDER, params, DESC_PLACEHOLDER, desc);
}
} else {
// No permission, nothing to see here. If you don't have permission, you cannot see any sub commands
return true;
}
} else if (!parent.isOnlyPlayer()) {
// Console. Only show if it is a console command
user.sendMessage(HELP_SYNTAX_REF, USAGE_PLACEHOLDER, usage, PARAMS_PLACEHOLDER, params, DESC_PLACEHOLDER, desc);
if (params.isEmpty()) {
user.sendMessage(HELP_SYNTAX_NO_PARAMETERS_REF, USAGE_PLACEHOLDER, usage, DESC_PLACEHOLDER, desc);
} else {
user.sendMessage(HELP_SYNTAX_REF, USAGE_PLACEHOLDER, usage, PARAMS_PLACEHOLDER, params, DESC_PLACEHOLDER, desc);
}
}
return false;
}

View File

@ -41,6 +41,7 @@ commands:
help:
header: "&7=========== &c[label] help &7==========="
syntax: "&b[usage] &a[parameters]&7: &e[description]"
syntax-no-parameters: "&b[usage]&7: &e[description]"
end: "&7================================="
parameters: "[command]"
description: "help command"