#293 Fix localized command losing its children

This commit is contained in:
ljacqu 2016-10-09 16:23:18 +02:00
parent 76e6d757da
commit 87f88cb32a
4 changed files with 21 additions and 2 deletions

View File

@ -62,7 +62,9 @@ public class HelpMessagesService implements Reloadable {
++i;
}
return builder.build();
CommandDescription localCommand = builder.build();
localCommand.getChildren().addAll(command.getChildren());
return localCommand;
}
public String getMessage(HelpMessage message) {

View File

@ -29,9 +29,10 @@ section:
# -------------------------------------------------------
# You can translate the data for all commands using the below pattern.
# So for example to translate /authme reload, create a section "authme.reload", or "login" for /login
# For example to translate /authme reload, create a section "authme.reload", or "login" for /login
# If the command has arguments, you can use arg1 as below to translate the first argument, and so forth
# Translations don't need to be complete; any missing section will be taken from the default silently
# Important: Put main commands like "authme" before their children (e.g. "authme.reload")
commands:
authme.register:
description: 'Register a player'

View File

@ -92,6 +92,20 @@ public class HelpMessagesServiceTest {
assertThat(localCommand, sameInstance(command));
}
@Test
public void shouldKeepChildrenInLocalCommand() {
// given
CommandDescription command = TestCommandsUtil.getCommandWithLabel(COMMANDS, "authme");
// when
CommandDescription localCommand = helpMessagesService.buildLocalizedDescription(command);
// then
assertThat(localCommand.getChildren(), equalTo(command.getChildren()));
assertThat(localCommand.getDescription(), equalTo("authme cmd"));
assertThat(localCommand.getDetailedDescription(), equalTo("Main command"));
}
@Test
public void shouldGetTranslationsForSectionAndMessage() {
// given / when / then

View File

@ -7,6 +7,8 @@ section:
arguments: 'arg.'
commands:
authme:
detailedDescription: 'Main command'
authme.register:
description: 'Registration'
detailedDescription: 'Registers the player'