Search in sources :

Example 21 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class CommandPageCreater method addCommandsInfo.

private static void addCommandsInfo(NestedTagValue commandTags, Collection<CommandDescription> commands) {
    for (CommandDescription command : commands) {
        TagValueHolder tags = TagValueHolder.create().put("command", CommandUtils.constructCommandPath(command)).put("description", command.getDetailedDescription()).put("arguments", formatArguments(command.getArguments())).put("permissions", formatPermissions(command.getPermission()));
        commandTags.add(tags);
        if (!command.getChildren().isEmpty()) {
            addCommandsInfo(commandTags, command.getChildren());
        }
    }
}
Also used : TagValueHolder(tools.utils.TagValueHolder) CommandDescription(fr.xephi.authme.command.CommandDescription)

Example 22 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class GeneratePluginYml method generateCommands.

private static Map<String, Object> generateCommands() {
    Collection<CommandDescription> commands = new CommandInitializer().getCommands();
    Map<String, Object> entries = new LinkedHashMap<>();
    for (CommandDescription command : commands) {
        entries.put(command.getLabels().get(0), buildCommandEntry(command));
    }
    return entries;
}
Also used : CommandDescription(fr.xephi.authme.command.CommandDescription) CommandInitializer(fr.xephi.authme.command.CommandInitializer) LinkedHashMap(java.util.LinkedHashMap)

Example 23 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class HelpTranslationVerifier method buildCommandPaths.

private Set<String> buildCommandPaths() {
    Set<String> commandPaths = new LinkedHashSet<>();
    for (CommandDescription command : new CommandInitializer().getCommands()) {
        commandPaths.addAll(getYamlPaths(command));
        command.getChildren().forEach(child -> commandPaths.addAll(getYamlPaths(child)));
    }
    return commandPaths;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CommandDescription(fr.xephi.authme.command.CommandDescription) CommandInitializer(fr.xephi.authme.command.CommandInitializer)

Example 24 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class HelpMessagesConsistencyTest method shouldHaveIdenticalTexts.

@Test
public void shouldHaveIdenticalTexts() {
    // given
    CommandDescription description = getAuthMeRegisterDescription();
    FileConfiguration configuration = YamlConfiguration.loadConfiguration(DEFAULT_MESSAGES_FILE);
    final String path = "commands.authme.register.";
    // when / then
    assertThat(configuration.get(path + "description"), equalTo(description.getDescription()));
    assertThat(configuration.get(path + "detailedDescription"), equalTo(description.getDetailedDescription()));
    assertThat(configuration.get(path + "arg1.label"), equalTo(description.getArguments().get(0).getName()));
    assertThat(configuration.get(path + "arg1.description"), equalTo(description.getArguments().get(0).getDescription()));
    assertThat(configuration.get(path + "arg2.label"), equalTo(description.getArguments().get(1).getName()));
    assertThat(configuration.get(path + "arg2.description"), equalTo(description.getArguments().get(1).getDescription()));
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) CommandDescription(fr.xephi.authme.command.CommandDescription) Test(org.junit.Test)

Example 25 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class HelpMessagesConsistencyTest method getAuthMeRegisterDescription.

/**
     * @return the CommandDescription object for the {@code /authme register} command.
     */
private static CommandDescription getAuthMeRegisterDescription() {
    Collection<CommandDescription> commands = new CommandInitializer().getCommands();
    List<CommandDescription> children = commands.stream().filter(command -> command.getLabels().contains("authme")).map(CommandDescription::getChildren).findFirst().get();
    return children.stream().filter(child -> child.getLabels().contains("register")).findFirst().get();
}
Also used : Collection(java.util.Collection) MemorySection(org.bukkit.configuration.MemorySection) Test(org.junit.Test) CommandInitializer(fr.xephi.authme.command.CommandInitializer) File(java.io.File) CommandDescription(fr.xephi.authme.command.CommandDescription) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Matchers.equalTo(org.hamcrest.Matchers.equalTo) TestHelper(fr.xephi.authme.TestHelper) CommandDescription(fr.xephi.authme.command.CommandDescription) CommandInitializer(fr.xephi.authme.command.CommandInitializer)

Aggregations

CommandDescription (fr.xephi.authme.command.CommandDescription)38 Test (org.junit.Test)30 Matchers.containsString (org.hamcrest.Matchers.containsString)22 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)22 FoundCommandResult (fr.xephi.authme.command.FoundCommandResult)20 CommandInitializer (fr.xephi.authme.command.CommandInitializer)4 CommandSender (org.bukkit.command.CommandSender)3 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)2 TestHelper (fr.xephi.authme.TestHelper)1 CommandArgumentDescription (fr.xephi.authme.command.CommandArgumentDescription)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 MemorySection (org.bukkit.configuration.MemorySection)1 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1