Advertisement
Guest User

Untitled

a guest
Nov 10th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. public void loadConfig() {
  2. file = new File(getDataFolder().getPath(), "config.yml");
  3. try {
  4. configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
  5. if(!getDataFolder().exists()) {
  6. getDataFolder().mkdir();
  7. }
  8. if(!file.exists()) {
  9. file.createNewFile();
  10. configuration.set("MySQL.Host", host);
  11. configuration.set("MySQL.username", username);
  12. configuration.set("MySQL.port", port);
  13. configuration.set("MySQL.password", password);
  14. configuration.set("MySQL.database", database);
  15. saveConfig();
  16. }
  17. } catch(IOException e) {
  18. e.printStackTrace();
  19. }
  20.  
  21. if(file.exists()) {
  22. host = configuration.getString("MySQL.Host");
  23. username = configuration.getString("MySQL.username");
  24. port = configuration.getString("MySQL.port");
  25. password = configuration.getString("MySQL.password");
  26. database = configuration.getString("MySQL.database");
  27.  
  28. MySQL sql = new MySQL(host, port, password, database, username);
  29. sql.connect();
  30. sql.createTable();
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement