Search in sources :

Example 6 with Configuration

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

the class FireWL method getIP.

public String getIP(String name) throws IOException {
    if (this.containsIP(name)) {
        File file = new File(plugin.getDataFolder(), "whitelist.yml");
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
        return config.getString("players." + name + ".ip");
    }
    return null;
}
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 7 with Configuration

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

the class FireWhiteListCommand method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    if (!this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
        sender.sendMessage(new TextComponent(this.pre + "§cVous n'avez pas la permission d'utiliser cette commande !"));
        return;
    }
    if (args.length == 0) {
        sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
        return;
    } else if (args.length == 1) {
        if (args[0].equalsIgnoreCase("on")) {
            File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
            try {
                Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
                config.set("enable", true);
                ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
                sender.sendMessage(new TextComponent(this.pre + "§aLe plugin est activé !"));
                this.api.getWhitelistSystem().setEnable(true);
            } catch (IOException e) {
                sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
            }
        } else if (args[0].equalsIgnoreCase("off")) {
            File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
            try {
                Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
                config.set("enable", false);
                ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
                sender.sendMessage(new TextComponent(this.pre + "§aLe plugin est désactivé !"));
                this.api.getWhitelistSystem().setEnable(false);
            } catch (IOException e) {
                sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
            }
        } else {
            sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
            return;
        }
    } else if (args.length == 2) {
        if (this.api.getWhitelistSystem().isEnable() == false) {
            sender.sendMessage(new TextComponent(this.pre + "§cLe plugin est désactivé !"));
            return;
        }
        if (args[0].equalsIgnoreCase("add")) {
            try {
                File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
                Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
                if (config.getBoolean("players." + args[1] + ".accepted") == true) {
                    sender.sendMessage(new TextComponent(this.pre + "§cLe joueur " + args[1] + " est déjà dans la whitelist !"));
                    return;
                }
                config.set("players." + args[1] + ".accepted", true);
                ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
                sender.sendMessage(new TextComponent(this.pre + "§aVous avez ajouté le joueur " + args[1] + " à la whitelist !"));
                return;
            } catch (IOException e) {
                sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
            }
        } else if (args[0].equalsIgnoreCase("remove")) {
            try {
                File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
                Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
                if (config.getBoolean("players." + args[1] + ".accepted") == false) {
                    sender.sendMessage(new TextComponent(this.pre + "§cLe joueur " + args[1] + " n'existe pas !"));
                    return;
                }
                config.set("players." + args[1] + ".accepted", false);
                ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
                sender.sendMessage(new TextComponent(this.pre + "§aVous avez retiré le joueur " + args[1] + " de la WhiteList !"));
            } catch (IOException e) {
                sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
            }
        } else {
            sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
            return;
        }
    } else {
        sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
        return;
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) IOException(java.io.IOException) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) File(java.io.File)

Example 8 with Configuration

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

the class FireFriends method loadConfiguration.

public void loadConfiguration() throws IOException {
    File file = new File(this.instance.getDataFolder(), "friends.yml");
    this.file = file;
    if (!file.exists()) {
        file.createNewFile();
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
        config.set("enable", true);
        ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
        this.enable = true;
    } else {
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
        this.enable = config.getBoolean("enable");
        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 9 with Configuration

use of net.md_5.bungee.config.Configuration in project ViaCheckConnection by x9nico.

the class Bungee method join.

@SuppressWarnings({ "unchecked" })
@EventHandler
public void join(ServerConnectedEvent e) throws IOException {
    ProxiedPlayer p = e.getPlayer();
    Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
    if (Bungee.isProtocolSupport()) {
        if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_8.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_8").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_9").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_1.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_9_1").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_2.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_9_2").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_3.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_9_3").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_10.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_10").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_11.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_11").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_11_1.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_11_1").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_12").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.unknown.getId()) {
            p.sendMessage(new TextComponent(config.getString("unknown_version").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_7_1.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_7_1").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_7_6.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_7_6").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12_1.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_12_1").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12_2.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_12_2").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_13.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_13").replace("&", "§")));
        }
    } else {
        if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_8.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_8").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_9").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_1.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_9_1").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_2.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_9_2").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_3.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_9_3").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_10.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_10").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_11.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_11").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_11_1.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_11_1").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_12").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.unknown.getId()) {
            p.sendMessage(new TextComponent(config.getString("unknown_version").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12_1.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_12_1").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12_2.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_12_2").replace("&", "§")));
        } else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_13.getId()) {
            p.sendMessage(new TextComponent(config.getString("v1_13").replace("&", "§")));
        }
    }
}
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) File(java.io.File) EventHandler(net.md_5.bungee.event.EventHandler)

Example 10 with Configuration

use of net.md_5.bungee.config.Configuration in project ViaCheckConnection by x9nico.

the class Bungee method onEnable.

@Override
public void onEnable() {
    getLogger().info("You are using the plugin on a BungeeCord proxy. Don't forget to remove it from your Spigot servers.");
    getLogger().info("Plugin version: " + getDescription().getVersion());
    getProxy().getPluginManager().registerListener(this, this);
    // Creates config.
    if (!getDataFolder().exists()) {
        getDataFolder().mkdir();
    }
    File configFile = new File(getDataFolder(), "config.yml");
    if (!configFile.exists()) {
        try {
            configFile.createNewFile();
            try (InputStream is = getResourceAsStream("config.yml");
                OutputStream os = new FileOutputStream(configFile)) {
                ByteStreams.copy(is, os);
            }
        } catch (IOException e) {
            throw new RuntimeException("Unable to create configuration file.", e);
        }
    }
    // Loads config.
    try {
        ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
    } catch (IOException e2) {
        throw new RuntimeException("Unable to load configuration file.", e2);
    }
    new Metrics(this);
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) 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