Search in sources :

Example 1 with TagValueHolder

use of tools.utils.TagValueHolder in project AuthMeReloaded by AuthMe.

the class HashAlgorithmsDescriptionTask method constructMethodRows.

private static NestedTagValue constructMethodRows(Map<HashAlgorithm, MethodDescription> descriptions) {
    NestedTagValue methodTags = new NestedTagValue();
    for (Map.Entry<HashAlgorithm, MethodDescription> entry : descriptions.entrySet()) {
        MethodDescription description = entry.getValue();
        TagValueHolder tags = TagValueHolder.create().put("name", asString(entry.getKey())).put("recommendation", asString(description.getUsage())).put("hash_length", asString(description.getHashLength())).put("ascii_restricted", asString(description.isAsciiRestricted())).put("salt_type", asString(description.getSaltType())).put("salt_length", asString(description.getSaltLength())).put("separate_salt", asString(description.hasSeparateSalt()));
        methodTags.add(tags);
    }
    return methodTags;
}
Also used : TagValueHolder(tools.utils.TagValueHolder) NestedTagValue(tools.utils.TagValue.NestedTagValue) Map(java.util.Map) HashAlgorithm(fr.xephi.authme.security.HashAlgorithm)

Example 2 with TagValueHolder

use of tools.utils.TagValueHolder in project AuthMeReloaded by AuthMe.

the class TranslationPageGenerator method executeDefault.

@Override
public void executeDefault() {
    TranslationsGatherer gatherer = new TranslationsGatherer();
    NestedTagValue translationValuesHolder = new NestedTagValue();
    for (TranslationInfo translation : gatherer.getTranslationInfo()) {
        int percentage = (int) Math.round(translation.getPercentTranslated() * 100);
        String name = Optional.ofNullable(LANGUAGE_NAMES.get(translation.getCode())).orElse("?");
        TagValueHolder valueHolder = TagValueHolder.create().put("code", translation.getCode()).put("name", name).put("percentage", Integer.toString(percentage)).put("color", computeColor(percentage));
        translationValuesHolder.add(valueHolder);
    }
    TagValueHolder tags = TagValueHolder.create().put("languages", translationValuesHolder);
    FileIoUtils.generateFileFromTemplate(TEMPLATE_FILE, DOCS_PAGE, tags);
    System.out.println("Wrote to '" + DOCS_PAGE + "'");
}
Also used : TagValueHolder(tools.utils.TagValueHolder) NestedTagValue(tools.utils.TagValue.NestedTagValue) TranslationInfo(tools.docs.translations.TranslationsGatherer.TranslationInfo)

Example 3 with TagValueHolder

use of tools.utils.TagValueHolder 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 4 with TagValueHolder

use of tools.utils.TagValueHolder in project AuthMeReloaded by AuthMe.

the class PermissionsListWriter method executeDefault.

@Override
public void executeDefault() {
    final NestedTagValue permissionsTagValue = generatePermissionsList();
    TagValueHolder tags = TagValueHolder.create().put("nodes", permissionsTagValue);
    FileIoUtils.generateFileFromTemplate(TEMPLATE_FILE, PERMISSIONS_OUTPUT_FILE, tags);
    System.out.println("Wrote to '" + PERMISSIONS_OUTPUT_FILE + "'");
}
Also used : TagValueHolder(tools.utils.TagValueHolder) NestedTagValue(tools.utils.TagValue.NestedTagValue)

Example 5 with TagValueHolder

use of tools.utils.TagValueHolder in project AuthMeReloaded by AuthMe.

the class UpdateConfigPageTask method executeDefault.

@Override
public void executeDefault() {
    File config = null;
    try {
        // Create empty temporary .yml file and save the config to it
        config = File.createTempFile("authme-config-", ".yml");
        SettingsManager settingsManager = SettingsManagerBuilder.withYamlFile(config).configurationData(AuthMeSettingsRetriever.buildConfigurationData()).create();
        settingsManager.save();
        // Get the contents and generate template file
        TagValueHolder tagValueHolder = TagValueHolder.create().put("config", FileIoUtils.readFromFile(config.toPath()));
        FileIoUtils.generateFileFromTemplate(TEMPLATE_FILE, OUTPUT_FILE, tagValueHolder);
        System.out.println("Wrote to '" + OUTPUT_FILE + "'");
    } catch (IOException e) {
        throw new IllegalStateException(e);
    } finally {
        FileUtils.delete(config);
    }
}
Also used : SettingsManager(ch.jalu.configme.SettingsManager) TagValueHolder(tools.utils.TagValueHolder) IOException(java.io.IOException) File(java.io.File)

Aggregations

TagValueHolder (tools.utils.TagValueHolder)6 NestedTagValue (tools.utils.TagValue.NestedTagValue)4 HashAlgorithm (fr.xephi.authme.security.HashAlgorithm)2 SettingsManager (ch.jalu.configme.SettingsManager)1 CommandDescription (fr.xephi.authme.command.CommandDescription)1 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1 TranslationInfo (tools.docs.translations.TranslationsGatherer.TranslationInfo)1