Add config option to disable verbose usage strings (#4396)

Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com>

```yml
# Whether or not Essentials should show detailed command usages.
# If set to false, Essentials will collapse all usages in to one single usage message.
verbose-command-usages: true
```

This PR also fixes a regression in legacy usage strings where the `<command>` wasn't replaced.
This commit is contained in:
Josh Roy 2021-08-09 12:56:38 -07:00 committed by GitHub
parent ac8a13f039
commit 42293596f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 2 deletions

View File

@ -770,12 +770,12 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
sender.sendMessage(tl("commandHelpLine1", commandLabel));
sender.sendMessage(tl("commandHelpLine2", command.getDescription()));
sender.sendMessage(tl("commandHelpLine3"));
if (!cmd.getUsageStrings().isEmpty()) {
if (getSettings().isVerboseCommandUsages() && !cmd.getUsageStrings().isEmpty()) {
for (Map.Entry<String, String> usage : cmd.getUsageStrings().entrySet()) {
sender.sendMessage(tl("commandHelpLineUsage", usage.getKey().replace("<command>", commandLabel), usage.getValue()));
}
} else {
sender.sendMessage(command.getUsage());
sender.sendMessage(command.getUsage().replace("<command>", commandLabel));
}
if (!ex.getMessage().isEmpty()) {
sender.sendMessage(ex.getMessage());

View File

@ -126,6 +126,8 @@ public interface ISettings extends IConf {
Set<String> getDisabledCommands();
boolean isVerboseCommandUsages();
boolean isCommandOverridden(String name);
boolean isDebug();

View File

@ -289,6 +289,11 @@ public class Settings implements net.ess3.api.ISettings {
return disabledCommands;
}
@Override
public boolean isVerboseCommandUsages() {
return config.getBoolean("verbose-command-usages", true);
}
private void _addAlternativeCommand(final String label, final Command current) {
Command cmd = ess.getAlternativeCommandsHandler().getAlternative(label);
if (cmd == null) {

View File

@ -170,6 +170,10 @@ disabled-commands:
# - nick
# - clear
# Whether or not Essentials should show detailed command usages.
# If set to false, Essentials will collapse all usages in to one single usage message.
verbose-command-usages: true
# These commands will be shown to players with socialSpy enabled.
# You can add commands from other plugins you may want to track or
# remove commands that are used for something you dont want to spy on.