58 lines
1.9 KiB
Java
58 lines
1.9 KiB
Java
package de.jatitv.commandguiv2.Bungee;
|
|
|
|
import net.md_5.bungee.config.Configuration;
|
|
import net.md_5.bungee.config.ConfigurationProvider;
|
|
import net.md_5.bungee.config.YamlConfiguration;
|
|
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
|
import net.t2code.lib.Util;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.nio.file.Files;
|
|
|
|
public class BConfig {
|
|
|
|
public static void create() {
|
|
|
|
if (!BMain.plugin.getDataFolder().exists())
|
|
BMain.plugin.getDataFolder().mkdir();
|
|
|
|
File file = new File(BMain.plugin.getDataFolder(), "config.yml");
|
|
|
|
|
|
if (!file.exists()) {
|
|
try (InputStream in = BMain.plugin.getResourceAsStream("config.yml")) {
|
|
Files.copy(in, file.toPath());
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
Configuration configuration;
|
|
try {
|
|
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(BMain.plugin.getDataFolder(), "config.yml"));
|
|
BMySQL.Enable = configuration.getBoolean("MySQL.Enable");
|
|
} catch (IOException e) {
|
|
Bsend.console(Util.Prefix + " Please replace the config: MySQL.Enable: [false,true]");
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(BMain.plugin.getDataFolder(), "config.yml"));
|
|
BMySQL.ip = configuration.getString("MySQL.IP");
|
|
BMySQL.port = configuration.getInt("MySQL.Port");
|
|
BMySQL.database = configuration.getString("MySQL.Database");
|
|
BMySQL.user = configuration.getString("MySQL.User");
|
|
BMySQL.password = configuration.getString("MySQL.Password");
|
|
BMySQL.SSL = configuration.getBoolean("MySQL.SSL");
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|