Advertisement
Zo0PlayzHD

MinersNation.de | FileManager BanSystem | MySQL

Oct 1st, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. package me.lukas.ban;
  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 me.lukas.main.Main;
  10. import net.md_5.bungee.api.ChatColor;
  11.  
  12. public class FileManager{
  13.  
  14. public static File getConfigFile() {
  15. return new File("plugins/BanSystem", "config.yml");
  16. }
  17.  
  18. public static FileConfiguration getConfigFileConfiguration() {
  19. return YamlConfiguration.loadConfiguration(getConfigFile());
  20. }
  21.  
  22. public static File getMySQLFile() {
  23. return new File("plugins/BanSystem", "mysql.yml");
  24. }
  25.  
  26. public static FileConfiguration getMySQLFileConfiguration() {
  27. return YamlConfiguration.loadConfiguration(getMySQLFile());
  28. }
  29.  
  30. public static void setStandardConfig() {
  31. FileConfiguration cfg = getConfigFileConfiguration();
  32. cfg.options().copyDefaults(true);
  33. cfg.addDefault("prefix", "§7[§bBan System§7]");
  34. try{
  35. cfg.save(getConfigFile());
  36. }catch (IOException e) {
  37. e.printStackTrace();
  38. }
  39. }
  40.  
  41. public static void readConfig() {
  42. FileConfiguration cfg = getConfigFileConfiguration();
  43. Main.getInstance().prefix = ChatColor.translateAlternateColorCodes('&', cfg.getString("prefix")) + " §r";
  44.  
  45. }
  46.  
  47. public static void setStandardSySQL() {
  48. FileConfiguration cfg = getMySQLFileConfiguration();
  49. cfg.options().copyDefaults(true);
  50. cfg.addDefault("username", "db_43381");
  51. cfg.addDefault("password", "password");
  52. cfg.addDefault("database", "mysql.mc-host24.de");
  53. cfg.addDefault("host", "mysql.mc-host24.de");
  54. cfg.addDefault("port", "25565");
  55. try {
  56. cfg.save(getMySQLFile());
  57. } catch (IOException e) {
  58. e.printStackTrace();
  59. }
  60. }
  61.  
  62. public static void readMySQL() {
  63. FileConfiguration cfg = getMySQLFileConfiguration();
  64. MySQL.username = cfg.getString("username");
  65. MySQL.password = cfg.getString("password");
  66. MySQL.database = cfg.getString("database");
  67. MySQL.host = cfg.getString("host");
  68. MySQL.port = cfg.getString("port");
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement