From 8a16940e14f23a4b37df34fff9e83868f2571f86 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Fri, 14 Dec 2018 15:44:33 +0100 Subject: [PATCH] Added 'commands.help.syntax-no-parameters' to avoid command help layout inconsistencies Fixes #379 --- .../bentobox/api/commands/DefaultHelpCommand.java | 13 +++++++++++-- src/main/resources/locales/en-US.yml | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/DefaultHelpCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/DefaultHelpCommand.java index 8324f8250..9275d84bc 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/DefaultHelpCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/DefaultHelpCommand.java @@ -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; } diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 5ec09a0c5..9e078fe2a 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -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"