Made use of "commands.help.syntax" for help

This is a more flexible and natural way to provide the display for the help, especially for the colors.

I had to remove the "/" from the usage though. If you think it should be there, re-add it but remove it from the locale then.
This commit is contained in:
Florian CUNY 2018-01-03 16:11:45 +01:00
parent 6536ff58cc
commit 44742d8946
4 changed files with 9 additions and 15 deletions

View File

@ -27,15 +27,9 @@ general:
commands:
help:
color:
usage: "&E"
parameters: "&B"
description: "&2"
header: "&7=========== &c%bsb_plugin_name% &7==========="
syntax: " &7/&b[label] &c[command] &a[args] &7: &e[info]"
syntax-alias-separator: "/"
syntax: "&7/&b[usage] &a[parameters] &7: &e[description]"
end: "&7================================="
about: "display this help page"
admin:
help:
description: "Admin command"

View File

@ -55,7 +55,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
*/
private String parameters = "";
/**
* The command chain from the very top, e.g., /island team promote
* The command chain from the very top, e.g., island team promote
*/
private String usage;
@ -304,7 +304,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
this.usage = parent.getLabel() + " " + this.usage;
parent = parent.getParent();
}
this.usage = "/" + this.usage;
this.usage = this.usage;
this.usage = this.usage.trim();
return this;
}

View File

@ -28,21 +28,21 @@ public class DefaultHelpCommand extends CompositeCommand {
if (args.isEmpty()) {
if (!parent.getLabel().equals("help")) {
// Get elements
String usage = parent.getUsage().isEmpty() ? "" : user.getTranslationOrNothing("commands.help.color.usage") + user.getTranslation(parent.getUsage());
String params = getParameters().isEmpty() ? "" : ChatColor.RESET + " " + user.getTranslationOrNothing("commands.help.color.parameters") + user.getTranslation(getParameters());
String desc = getDescription().isEmpty() ? "" : ChatColor.RESET + user.getTranslationOrNothing("commands.help.color.description") + " " + user.getTranslation(getDescription());
String usage = parent.getUsage().isEmpty() ? "" : user.getTranslation(parent.getUsage());
String params = getParameters().isEmpty() ? "" : user.getTranslation(getParameters());
String desc = getDescription().isEmpty() ? "" : user.getTranslation(getDescription());
// Show the help
if (user.isPlayer()) {
// Player. Check perms
if (user.hasPermission(parent.getPermission())) {
user.sendRawMessage(usage + params + desc);
user.sendMessage("commands.help.syntax", "[usage]", usage, "[parameters]", params, "[description]", 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.sendRawMessage(usage + params + desc);
user.sendMessage("commands.help.syntax", "[usage]", usage, "[parameters]", params, "[description]", desc);
}
}
// Run through any subcommands and get their help

View File

@ -131,7 +131,7 @@ public class TestBSkyBlock {
assertTrue(testCommand.execute(player, "test", new String[] {"sub2", "subsub", "subsubsub", "ben", "100", "today"}));
// Usage tests
assertEquals("/test", testCommand.getUsage());
assertEquals("test", testCommand.getUsage());
assertEquals("test.params", testCommand.getParameters());
// Test help