CompositeCommand : added defaults for setDescription and setParameters

This commit is contained in:
Florian CUNY 2018-08-01 10:36:38 +02:00
parent b600dacbdd
commit 1a63b2431e

View File

@ -119,6 +119,9 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
if (plugin.getCommand(label) == null) { if (plugin.getCommand(label) == null) {
plugin.getCommandsManager().registerCommand(this); plugin.getCommandsManager().registerCommand(this);
} }
// Default references to description and parameters
setDescription("commands." + label + ".description");
setParameters("commands." + label + ".parameters");
setup(); setup();
if (!getSubCommand("help").isPresent() && !label.equals("help")) { if (!getSubCommand("help").isPresent() && !label.equals("help")) {
new DefaultHelpCommand(this); new DefaultHelpCommand(this);
@ -160,6 +163,14 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
this.permissionPrefix = parent.getPermissionPrefix(); this.permissionPrefix = parent.getPermissionPrefix();
// Inherit world // Inherit world
this.world = parent.getWorld(); this.world = parent.getWorld();
// Default references to description and parameters
String reference = "";
for (CompositeCommand p = this ; p != null ; p = getParent()) {
reference = "." + p.getLabel() + reference;
}
reference = "commands" + reference;
setDescription(reference + ".description");
setParameters(reference + ".parameters");
setup(); setup();
// If this command does not define its own help class, then use the default help command // If this command does not define its own help class, then use the default help command
if (!getSubCommand("help").isPresent() && !label.equals("help")) { if (!getSubCommand("help").isPresent() && !label.equals("help")) {