Search in sources :

Example 1 with YamlConfiguration

use of org.bukkit.configuration.file.YamlConfiguration in project EliteMobs by MagmaGuy.

the class CustomConfigLoader method reloadCustomConfig.

public void reloadCustomConfig(String configName) {
    if (customConfigFile == null) {
        customConfigFile = new File(plugin.getDataFolder(), configName);
    }
    customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
    // Look for defaults in the jar
    Reader defConfigStream = null;
    try {
        defConfigStream = new InputStreamReader(plugin.getResource(configName), "UTF8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    if (defConfigStream != null) {
        YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(customConfigFile);
        customConfig.setDefaults(defConfig);
    }
}
Also used : InputStreamReader(org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader) InputStreamReader(org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader) Reader(java.io.Reader) UnsupportedEncodingException(java.io.UnsupportedEncodingException) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) File(java.io.File)

Example 2 with YamlConfiguration

use of org.bukkit.configuration.file.YamlConfiguration in project TotalFreedomMod by TotalFreedom.

the class MainConfig method load.

public void load() {
    try {
        YamlConfiguration config = new YamlConfiguration();
        config.load(getConfigFile());
        for (ConfigEntry entry : ConfigEntry.values()) {
            String path = entry.getConfigName();
            if (config.contains(path)) {
                Object value = config.get(path);
                if (value == null || entry.getType().isAssignableFrom(value.getClass())) {
                    entries.put(entry, value);
                } else {
                    FLog.warning("Value for " + entry.getConfigName() + " is of type " + value.getClass().getSimpleName() + ". Needs to be " + entry.getType().getSimpleName() + ". Using default value.");
                }
            } else {
                FLog.warning("Missing configuration entry " + entry.getConfigName() + ". Using default value.");
            }
        }
    } catch (IOException | InvalidConfigurationException ex) {
        FLog.severe(ex);
    }
}
Also used : IOException(java.io.IOException) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException)

Example 3 with YamlConfiguration

use of org.bukkit.configuration.file.YamlConfiguration in project GameCore by Warvale.

the class ConfigManager method reloadLobby.

public void reloadLobby() {
    try {
        lobby = new YamlConfiguration();
        lobby.load(lobbyFile);
    } catch (Exception ex) {
        Main.get().getLogger().severe("Could not reload config: " + lobbyFile.getName());
    }
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration)

Example 4 with YamlConfiguration

use of org.bukkit.configuration.file.YamlConfiguration in project GameCore by Warvale.

the class ConfigManager method reloadConfig.

public void reloadConfig() {
    try {
        config = new YamlConfiguration();
        config.load(configFile);
    } catch (Exception ex) {
        Main.get().getLogger().severe("Could not reload config: " + configFile.getName());
    }
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration)

Example 5 with YamlConfiguration

use of org.bukkit.configuration.file.YamlConfiguration in project GameCore by Warvale.

the class ConfigManager method reloadMessages.

public void reloadMessages() {
    try {
        messages = new YamlConfiguration();
        messages.load(messageFile);
    } catch (Exception ex) {
        Main.get().getLogger().severe("Could not reload config: " + messageFile.getName());
    }
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration)

Aggregations

YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)16 File (java.io.File)7 IOException (java.io.IOException)7 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)5 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)3 ChatColor (com.gamingmesh.jobs.util.ChatColor)2 InputStream (java.io.InputStream)2 Location (org.bukkit.Location)2 World (org.bukkit.World)2 Test (org.junit.Test)2 ActionType (com.gamingmesh.jobs.container.ActionType)1 DisplayMethod (com.gamingmesh.jobs.container.DisplayMethod)1 Job (com.gamingmesh.jobs.container.Job)1 JobInfo (com.gamingmesh.jobs.container.JobInfo)1 JobPermission (com.gamingmesh.jobs.container.JobPermission)1 RestrictedArea (com.gamingmesh.jobs.container.RestrictedArea)1 Title (com.gamingmesh.jobs.container.Title)1 Parser (com.gamingmesh.jobs.resources.jfep.Parser)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1