|
| 1 | +package de.yellowphoenix18.uuidmethods.config; |
| 2 | + |
| 3 | +import java.io.File; |
| 4 | +import java.io.IOException; |
| 5 | + |
| 6 | +import org.bukkit.configuration.file.FileConfiguration; |
| 7 | +import org.bukkit.configuration.file.YamlConfiguration; |
| 8 | + |
| 9 | +import de.yellowphoenix18.uuidmethods.UUIDMethods; |
| 10 | + |
| 11 | +public class MainConfig { |
| 12 | + |
| 13 | + public static File f = new File("plugins/UUIDDatabse", "config.yml"); |
| 14 | + public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(f); |
| 15 | + |
| 16 | + public static boolean debug = false; |
| 17 | + |
| 18 | + public static void loadConfig() { |
| 19 | + if(cfg.getString("MYSQL.IP") == null) { |
| 20 | + cfg.set("MYSQL.IP", "localhost"); |
| 21 | + } |
| 22 | + if(cfg.getInt("MYSQL.Port") == 0) { |
| 23 | + cfg.set("MYSQL.Port", 3306); |
| 24 | + } |
| 25 | + if(cfg.getString("MYSQL.Username") == null) { |
| 26 | + cfg.set("MYSQL.Username", "Username"); |
| 27 | + } |
| 28 | + if(cfg.getString("MYSQL.Password") == null) { |
| 29 | + cfg.set("MYSQL.Password", "Password"); |
| 30 | + } |
| 31 | + if(cfg.getString("MYSQL.Database") == null) { |
| 32 | + cfg.set("MYSQL.Database", "Database"); |
| 33 | + } |
| 34 | + if(cfg.getBoolean("MYSQL.Enabled") == false) { |
| 35 | + cfg.set("MYSQL.Enabled", false); |
| 36 | + } |
| 37 | + if(cfg.getBoolean("Settings.Debug") == false) { |
| 38 | + cfg.set("Settings.Debug", false); |
| 39 | + } |
| 40 | + |
| 41 | + try { |
| 42 | + cfg.save(f); |
| 43 | + } catch (IOException e) { |
| 44 | + e.printStackTrace(); |
| 45 | + } |
| 46 | + |
| 47 | + UUIDMethods.username = cfg.getString("MYSQL.Username"); |
| 48 | + UUIDMethods.ip = cfg.getString("MYSQL.IP"); |
| 49 | + UUIDMethods.password = cfg.getString("MYSQL.Password"); |
| 50 | + UUIDMethods.database = cfg.getString("MYSQL.Database"); |
| 51 | + UUIDMethods.port = cfg.getInt("MYSQL.Port"); |
| 52 | + UUIDMethods.enabled = cfg.getBoolean("MYSQL.Enabled"); |
| 53 | + debug = cfg.getBoolean("Settings.Debug"); |
| 54 | + } |
| 55 | + |
| 56 | +} |
0 commit comments