Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. package de.diecloudapi.util;
  2.  
  3. import de.diecloudapi.main.Main;
  4. import org.bukkit.configuration.file.YamlConfiguration;
  5.  
  6. import java.io.File;
  7. import java.io.IOException;
  8.  
  9. public class Config {
  10.  
  11. public static File folder = new File("plugins/TTT/");
  12. public static File file = new File("plugins/TTT/Config.yml");
  13. public static YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  14.  
  15. public static void saveFiles() {
  16. try {
  17. cfg.save(file);
  18. } catch (IOException ex) {
  19.  
  20. }
  21.  
  22. Main.PREFIX = getConfigString("Config.Prefix");
  23. Main.MINPLAYERS = getConfigInt("Config.Minplayer");
  24. Main.MAXPLAYERS = getConfigInt("Config.Maxplayer");
  25.  
  26. }
  27.  
  28. public static String getConfigString(String path) {
  29. return cfg.getString(path).replace("&", "§");
  30. }
  31.  
  32. public static int getConfigInt(String path) {
  33. return cfg.getInt(path);
  34. }
  35.  
  36. public static void setupFiles() {
  37. if(!folder.exists()) {
  38. folder.mkdir();
  39. }
  40.  
  41. if(!file.exists()) {
  42. try {
  43. file.createNewFile();
  44. } catch (IOException ex) {
  45. ex.printStackTrace();
  46. }
  47. }
  48.  
  49. cfg.addDefault("Config.Prefix" , "&8[&cTTT&8] &r");
  50. cfg.addDefault("Config.Minplayer" , "1");
  51. cfg.addDefault("Config.Maxplayer" , "20");
  52.  
  53. cfg.options().copyDefaults(true);
  54. try {
  55. saveFiles();
  56. } catch (NullPointerException e1) {
  57.  
  58. }
  59. }
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement