Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package me.m4rk4yy.mysql;
  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. public class MySQLFile {
  10.    
  11.     public void setStandard() {
  12.        
  13.         FileConfiguration cfg = getFileConfiguration();
  14.        
  15.         cfg.options().copyDefaults(true);
  16.        
  17.         cfg.addDefault("host", "localhost");
  18.         cfg.addDefault("port", "3306");
  19.         cfg.addDefault("database", "test");
  20.         cfg.addDefault("username", "root");
  21.         cfg.addDefault("password", "");
  22.        
  23.         try {
  24.             cfg.save(getFile());
  25.         } catch (IOException e) {
  26.         }
  27.        
  28.     }
  29.    
  30.     private File getFile() {
  31.         return new File("plugins//IdentitySystem", "MySQL");
  32.     }
  33.    
  34.     private FileConfiguration getFileConfiguration() {
  35.         return YamlConfiguration.loadConfiguration(getFile());
  36.        
  37.     }
  38.     public void readData() {
  39.         FileConfiguration cfg = getFileConfiguration();
  40.        
  41.         MySQL.host = cfg.getString("host");
  42.         MySQL.port = cfg.getString("port");
  43.         MySQL.database = cfg.getString("database");
  44.         MySQL.username = cfg.getString("username");
  45.         MySQL.password = cfg.getString("password");
  46.        
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement