Search in sources :

Example 11 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project Denizen-For-Bukkit by DenizenScript.

the class EntityScriptHelper method saveEntities.

public static void saveEntities() {
    FileConfiguration entityScripts = DenizenAPI.getCurrentInstance().getEntities();
    entityScripts.set("entities.scripts", null);
    for (Map.Entry<UUID, String> entry : entities.entrySet()) {
        entityScripts.set("entities.scripts." + entry.getKey() + ".scriptname", entry.getValue());
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.

the class TranslationsGatherer method processMessagesFile.

private void processMessagesFile(String code, File file) {
    FileConfiguration configuration = YamlConfiguration.loadConfiguration(file);
    int availableMessages = 0;
    for (MessageKey key : MessageKey.values()) {
        if (configuration.contains(key.getKey())) {
            ++availableMessages;
        }
    }
    translationInfo.add(new TranslationInfo(code, (double) availableMessages / MessageKey.values().length));
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) MessageKey(fr.xephi.authme.message.MessageKey)

Example 13 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.

the class GeneratePluginYml method executeDefault.

@Override
public void executeDefault() {
    FileConfiguration configuration = loadPartialPluginYmlFile();
    configuration.set("commands", generateCommands());
    configuration.set("permissions", generatePermissions());
    FileIoUtils.writeToFile(PLUGIN_YML_FILE, pluginYmlStart + "\n" + configuration.saveToString());
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration)

Example 14 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.

the class CodeClimateConfigTest method shouldHaveExistingClassesInExclusions.

@Test
public void shouldHaveExistingClassesInExclusions() {
    // given
    FileConfiguration configuration = YamlConfiguration.loadConfiguration(new File(CONFIG_FILE));
    List<String> excludePaths = configuration.getStringList("exclude_paths");
    // when / then
    assertThat(excludePaths, not(empty()));
    for (String path : excludePaths) {
        String className = convertPathToQualifiedClassName(path);
        assertThat("No class corresponds to excluded path '" + path + "'", Utils.isClassLoaded(className), equalTo(true));
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) File(java.io.File) Test(org.junit.Test)

Example 15 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.

the class MessageUpdater method loadJarFileOrSendError.

private static FileConfiguration loadJarFileOrSendError(String jarPath) {
    try (InputStream stream = FileUtils.getResourceFromJar(jarPath)) {
        if (stream == null) {
            ConsoleLogger.info("Could not load '" + jarPath + "' from JAR");
            return null;
        }
        InputStreamReader isr = new InputStreamReader(stream);
        FileConfiguration configuration = YamlConfiguration.loadConfiguration(isr);
        close(isr);
        return configuration;
    } catch (IOException e) {
        ConsoleLogger.logException("Exception while handling JAR path '" + jarPath + "'", e);
    }
    return null;
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IOException(java.io.IOException)

Aggregations

FileConfiguration (org.bukkit.configuration.file.FileConfiguration)36 File (java.io.File)11 IOException (java.io.IOException)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)5 MinigameSave (au.com.mineauz.minigames.MinigameSave)4 HashMap (java.util.HashMap)4 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)4 Map (java.util.Map)3 MemorySection (org.bukkit.configuration.MemorySection)3 Player (org.bukkit.entity.Player)3 RewardsFlag (au.com.mineauz.minigames.config.RewardsFlag)2 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)2 MinigameModule (au.com.mineauz.minigames.minigame.modules.MinigameModule)2 DefaultInfo (de.Keyle.MyPet.api.entity.DefaultInfo)2 MyPetType (de.Keyle.MyPet.api.entity.MyPetType)2 ConfigurationYAML (de.Keyle.MyPet.api.util.configuration.ConfigurationYAML)2 InputStreamReader (java.io.InputStreamReader)2 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)2