recode Bungee config
This commit is contained in:
parent
ee587742d1
commit
b212b68f67
@ -1,56 +1,39 @@
|
||||
package de.jatitv.commandguiv2.Bungee;
|
||||
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
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 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();
|
||||
}
|
||||
public static void create() throws IOException {
|
||||
File config = new File(BMain.plugin.getDataFolder(), "config.yml");
|
||||
if (!BMain.plugin.getDataFolder().exists()) BMain.plugin.getDataFolder().mkdir();
|
||||
if (!config.exists()) {
|
||||
config.createNewFile();
|
||||
}
|
||||
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
|
||||
|
||||
configuration.set("MySQL.Enable", false);
|
||||
configuration.set("MySQL.IP", "localhost");
|
||||
configuration.set("MySQL.Port", 3306);
|
||||
configuration.set("MySQL.Database", "database");
|
||||
configuration.set("MySQL.User", "user");
|
||||
configuration.set("MySQL.Password", "");
|
||||
configuration.set("MySQL.SSL", false);
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, config);
|
||||
|
||||
|
||||
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.getSpigot() + " 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class BMain extends Plugin {
|
||||
@ -41,7 +42,11 @@ public final class BMain extends Plugin {
|
||||
Bsend.console(prefix + " §2Version: §6" + version);
|
||||
Bsend.console(prefix + " §2Spigot: §6" + spigot);
|
||||
Bsend.console(prefix + " §2Discord: §6" + discord);
|
||||
try {
|
||||
BConfig.create();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
plugin.getProxy().registerChannel("cgui:bungee");
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, new BListener());
|
||||
|
@ -33,7 +33,6 @@ public class BUpdateChecker {
|
||||
Bsend.console("§4=========== " + Prefix + " §4===========");
|
||||
}
|
||||
|
||||
|
||||
public static void onUpdateCheckTimer() {
|
||||
ProxyServer.getInstance().getScheduler().schedule(BMain.plugin, new Runnable() {
|
||||
public void run() {
|
||||
|
@ -1,8 +0,0 @@
|
||||
MySQL:
|
||||
Enable: false
|
||||
IP: localhost
|
||||
Port: 3306
|
||||
Database: database
|
||||
User: user
|
||||
Password: ''
|
||||
SSL: false
|
Loading…
Reference in New Issue
Block a user