Search in sources :

Example 21 with Configuration

use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.

the class FireWL method containsIP.

public boolean containsIP(String name) throws IOException {
    if (this.exists(name)) {
        File file = new File(plugin.getDataFolder(), "whitelist.yml");
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
        return config.contains("players." + name + ".ip");
    }
    return false;
}
Also used : YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) File(java.io.File)

Example 22 with Configuration

use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.

the class FireWL method loadConfiguration.

public void loadConfiguration() {
    try {
        if (!plugin.getDataFolder().exists()) {
            plugin.getDataFolder().mkdirs();
        }
        File file = new File(plugin.getDataFolder(), "whitelist.yml");
        if (!file.exists()) {
            file.createNewFile();
            Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
            config.set("enable", true);
            ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
            if (config.getBoolean("enable") == true) {
                enable = true;
            } else if (config.getBoolean("enable") == false) {
                enable = false;
            }
        } else {
            Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
            ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
            if (config.getBoolean("enable") == true) {
                enable = true;
            } else if (config.getBoolean("enable") == false) {
                enable = false;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) File(java.io.File) IOException(java.io.IOException)

Example 23 with Configuration

use of net.md_5.bungee.config.Configuration in project LuckPerms by lucko.

the class BungeeConfigAdapter method getMap.

@Override
public Map<String, String> getMap(String path, Map<String, String> def) {
    Map<String, String> map = new HashMap<>();
    Configuration section = this.configuration.getSection(path);
    if (section == null) {
        return def;
    }
    for (String key : section.getKeys()) {
        map.put(key, section.get(key).toString());
    }
    return map;
}
Also used : YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) HashMap(java.util.HashMap)

Example 24 with Configuration

use of net.md_5.bungee.config.Configuration in project DragonProxy by DragonetMC.

the class Config method save.

/**
 * Save the configuration to file
 *
 * @param fileConfiguration
 */
public void save(String fileConfiguration) {
    try {
        File ConfigurationFile = new File(this.plugin.getDataFolder(), fileConfiguration);
        if (!ConfigurationFile.exists())
            this.copyDefault(fileConfiguration);
        ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, ConfigurationFile);
        this.plugin.getLogger().info("Config saved!");
    } catch (IOException ex) {
        plugin.getLogger().log(Level.SEVERE, null, ex);
    }
}
Also used : IOException(java.io.IOException) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) File(java.io.File)

Example 25 with Configuration

use of net.md_5.bungee.config.Configuration in project ChangeSkin by games647.

the class ChangeSkinCore method load.

public void load(boolean database) {
    saveDefaultFile("messages.yml");
    saveDefaultFile("config.yml");
    try {
        config = loadFile("config.yml");
        int rateLimit = config.getInt("mojang-request-limit");
        cooldownService = new CooldownService(Duration.ofSeconds(config.getInt("cooldown")));
        autoUpdateDiff = Duration.ofMinutes(config.getInt("auto-skin-update"));
        List<HostAndPort> proxies = config.getStringList("proxies").stream().map(HostAndPort::fromString).collect(toList());
        skinApi = new MojangSkinApi(plugin.getLog(), rateLimit, proxies);
        if (database) {
            if (!setupDatabase(config.getSection("storage"))) {
                return;
            }
            loadDefaultSkins(config.getStringList("default-skins"));
            loadAccounts(config.getStringList("upload-accounts"));
        }
        Configuration messages = loadFile("messages.yml");
        messages.getKeys().stream().filter(key -> messages.get(key) != null).collect(toMap(identity(), messages::get)).forEach((key, message) -> {
            String colored = CommonUtil.translateColorCodes((String) message);
            if (!colored.isEmpty()) {
                localeMessages.put(key, colored.replace("/newline", "\n"));
            }
        });
    } catch (IOException ioEx) {
        plugin.getLog().info("Failed to load yaml file", ioEx);
    }
}
Also used : HostAndPort(com.google.common.net.HostAndPort) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) IOException(java.io.IOException)

Aggregations

YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)32 Configuration (net.md_5.bungee.config.Configuration)30 File (java.io.File)16 IOException (java.io.IOException)12 TextComponent (net.md_5.bungee.api.chat.TextComponent)6 InputStream (java.io.InputStream)5 ArrayList (java.util.ArrayList)5 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)5 Path (java.nio.file.Path)4 ConnectableAddress (de.dytanic.cloudnet.lib.ConnectableAddress)3 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)2 ServerInstallablePlugin (de.dytanic.cloudnet.lib.service.plugin.ServerInstallablePlugin)2 SimpledUser (de.dytanic.cloudnet.lib.user.SimpledUser)2 Document (de.dytanic.cloudnet.lib.utility.document.Document)2 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 URLConnection (java.net.URLConnection)2 Enumeration (java.util.Enumeration)2 Properties (java.util.Properties)2