Search in sources :

Example 16 with Configuration

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

the class FireFriends method removeFriend.

public void removeFriend(ProxiedPlayer p1, String p2) throws IOException {
    if (this.enable) {
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
        if (config.contains("data." + p1.getName()) && config.contains("data." + p2)) {
            List<String> list = config.getStringList("data." + p1.getName());
            if (list.contains(p2)) {
                list.remove(p2);
            }
            if (list.size() == 0) {
                config.set("data." + p1.getName(), null);
            } else {
                config.set("data." + p1.getName(), list);
            }
            List<String> list2 = config.getStringList("data." + p2);
            if (list2.contains(p1.getName())) {
                list2.remove(p1.getName());
            }
            if (list2.size() == 0) {
                config.set("data." + p2, null);
            } else {
                config.set("data." + p2, list2);
            }
            ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
            p1.sendMessage(new TextComponent(this.pre + "§aVous n'êtes plus ami avec " + p2));
        } else {
            p1.sendMessage(new TextComponent(this.pre + "§cErreur, vous n'êtes pas ami avec " + p2));
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration)

Example 17 with Configuration

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

the class FireFriends method getOnlineFriends.

public List<ProxiedPlayer> getOnlineFriends(ProxiedPlayer pp) throws IOException {
    Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
    List<ProxiedPlayer> connected = new ArrayList<>();
    List<String> list = config.getStringList("data." + pp.getName());
    for (String names : list) {
        try {
            ProxiedPlayer player = this.instance.getProxy().getPlayer(names);
            if (player != null) {
                connected.add(player);
            }
        } catch (Exception e) {
            continue;
        }
    }
    return connected;
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) ArrayList(java.util.ArrayList) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) IOException(java.io.IOException)

Example 18 with Configuration

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

the class FireFriends method sendGeneratedList.

public void sendGeneratedList(ProxiedPlayer pp) throws IOException {
    Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
    if (hasFriends(pp)) {
        if (getOnlineFriends(pp).size() == 0) {
            pp.sendMessage(new TextComponent(this.pre + "Vous n'avez §caucun§r ami connecté sur le serveur"));
        } else if (getOnlineFriends(pp).size() == 1) {
            pp.sendMessage(new TextComponent(this.pre + "Vous avez §eun§r ami connecté sur le serveur"));
        } else {
            pp.sendMessage(new TextComponent(this.pre + "Vous avez §e" + getOnlineFriends(pp).size() + "§r amis connectés sur le serveur"));
        }
    } else {
        pp.sendMessage(new TextComponent(this.pre + "§cVous n'avez pas d'amis :("));
        return;
    }
    List<String> list = config.getStringList("data." + pp.getName());
    for (ProxiedPlayer connected : getOnlineFriends(pp)) {
        pp.sendMessage(new TextComponent(this.pre + "§a" + connected.getName() + "§r est actuellement sur le §e" + connected.getServer().getInfo().getName()));
        list.remove(connected.getName());
    }
    for (String names : list) {
        pp.sendMessage(new TextComponent(this.pre + "§8" + names + "§r est actuellement §chors-ligne"));
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration)

Example 19 with Configuration

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

the class FireAuth method loadConfiguration.

public void loadConfiguration() throws IOException {
    File file = new File(this.main.getDataFolder(), "auth.yml");
    this.file = file;
    if (!file.exists()) {
        file.createNewFile();
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
        config.set("crypt-pass-key", "stalineestsympa");
        this.key = config.getString("crypt-pass-key");
        ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
    } else {
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
        this.key = config.getString("crypt-pass-key");
        ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
    }
}
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 20 with Configuration

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

the class FireWL method setDefault.

public void setDefault(String name, String ip) throws IOException {
    File file = new File(plugin.getDataFolder(), "whitelist.yml");
    Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
    if (config.getBoolean("players." + name + ".accepted") == true && config.contains("players." + name + ".ip")) {
        return;
    }
    if (config.getBoolean("players." + name + ".accepted") == true && !config.contains("players." + name + ".ip")) {
        config.set("players." + name + ".ip", ip);
        ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
        return;
    }
    config.set("players." + name + ".accepted", false);
    config.set("players." + name + ".ip", ip);
    ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
}
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)

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